Main Site Documentation

Fez Cerberus and SPI Clock


#1

The SPI clock doesn’t match the value in SPI.Configuration, is there a rule to calculate it ?


#2

Welcome to the forum!

What do you mean it doesn’t match?


#3

if I set the Clock_RateKhz to 1000 in the SPI.Configuration the real output frequency on the SCK pin is about 660 Khz.


#4

Usually if a SPI device documentation specify 1MHz, for example, and you set it to 1000 - it works. I have never actually needed to measure it.

Do you have a device that fails to communicate at that setting?


#5

I’m using the SPI to establish a full duplex communication with an ARM device (Tegra T30) and I need a precise clock frequency. I configured the Cerberus SPI as Master and the T30 SPI as slave, so the clock source is from Cerberus. Because I had trouble to communicate, I measured the frequency on the SPI SCK pin and it was about 660Khz instead of 1Mhz.
If I set the SPI Clock on the T30 at 660Khz the communication starts but some patterns from T30 to Cerberus are not good transferred.

example:

T30 TX: 01 01 01 01 01 01 01 01
Cerberus RX: 01 80 81 81 80 81 81 81

I supposed that it is related to the wrong clock frequency.


#6

That is due to the wrong clock setup not frequency.


#7

Hi Gus,
following the Spi setup line:

SPI.Configuration spiConfig = new SPI.Configuration(PA13_SPICS, false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);

but on the SPI SCK pin I measure always 660Khz instead of 1Mhz.


#8

What you see for frequency is probably fine. The clock is divided from a source so not all frequencies are possible. So when you say 1Mhz, you will get the highest possible frequency that is as close as possible to 1Mhz.

Now, your problem is not in the clock but in the setup. Like the clock edge and the idle state. These are in your config arguments, set to true or false.


#9

I have already tested all the 4 combinations of clock edges and clock idle state, but the results are always wrong or worse, I’m working with clock idle state = false and clock edge = true, on the T30 with SPI Mode 0 that coincides with above settings .
However I can confirm the following measurements:
SPI Clock Setting Measured Clock frequency
500Khz 328Khz
1000Khz 656Khz
1500Khz 1313Khz
unfortunately I cannot set spare SPI Clock frequency on the T30 device.
Do you have more info about the SPI, I found only this example in the Documents:
https://www.ghielectronics.com/docs/14/spi


#10

hi, i have the same issue… Any solution?
thanks!


#11

yes, in others NETMF boards i found a similar issue but in the docs i found that it’s necessary to divide by 255 the board clock rate to get the list of the possible speeds you can use. Maybe there are a similar way?
Thanks in advance


#12

How are you measuring the clock speed?


#13

Oscilloscope


#14

Hi Aniellogallo

I suggest a peruse of this document: http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00031020.pdf

[ul]8 master mode baud rate prescalers (fPCLK/2 max.)
Slave mode frequency (fPCLK/2 max)[/ul]

If you can post some code maybe we can help further also?

fPCLK might be 8MHz or 12MHz, or 1MHz, this figure needs to be checked to determine the prescaler.

See: fPCLK1 must be at least 2 MHz to achieve Sm mode I²C frequencies. P.852

All the best

Chris