This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Baud rate for SPI

Hi,

I have a question regarding the frequency of the SPI peripheral of the nrf52.

According to the Product Specification v1.4, the minimum value for the frequency is 125kbps, setting the register to 0x02000000

We have made a test with lower values and the spi peripheral seems to work fine.

Would it be possible to have your feedback about using lower values, not reported in the Product Specification document ?

Would it be possible to know the function f for f(clock_frequency) = Register Value, if exists ?

Thanks in advance for the support.

Kind regards

Riccardo

  • Hi,

    SPI and TWI share address space and some registers, but they're different peripherals. I don't know the internals, one can suppose that they're clocked from different PCLK sources.

  • Hi,

    ok, thanks again for the support.

    KR

    riccardo

  • Did you get this low speed clocking issue solved?

    I am trying to solve the same problem; was thinking to use SPIS instead of SPIM. SCK could be fed from a timer (possibly externally connected), which is costing me 2 extra pins. Don't know how that'll work for input though since we would need the clock to start from GPIO or continuously monitor if there's any data coming in from SPI. 

    If that won't work I'll just have to go with a PPI based GPIO / timer solution where a pin change triggers a timer value to be written into memory. Bit extra software required, should work for input but not for output. I don't think it's possible to drive GPIO from DMA, so I needed to come up with another clever solution there.

  • Hi jev,

    at the end it was possible to set lower speed than the ones reported in the manual (regarding the SPI peripheral), but note that there is a kind of approximation. I do not remember exactly the value of that (might be rounded_value = (value + 0x800) & 0xFFFFF000), so the consequence was that in my case i could not reach the SPI baudrate i wanted (9600 bit/sec).

    So, as you said, I tried the SPI slave feeding the clock with another pin of the Nordic configured as GPIO controlled with a TIMER (PPI approach). In order to control the Chip Select of the SPI I used to activate the its pull-down.

    I did a couple of test and it seems to work properly. In our product we did not adopt the SPI slave then, so I did not perform further and thorough tests. But I hope this could help you to give a try.

    Let me know if it works :)

    Riccardo

  • Well, I ended up using SPIM at almost 9600 bps, coding 1 bit in a SPI byte transfer. The spec says +/- 10% timing is allowed and I'm 1.5% fast so no worries there. Needed to add an IDLE bit before the start of the transfer because SPI starts clocking rather late. Prolly some optimizations still possible.

    Receiving is quite a bit more complicated since that is asynchronous. For now, it seems to work.

    The one thing it won't do is collision detection. O well...

Related