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

nRF5340 SPI frequency setting

Hi, 

I'm working on a code using SPI. 

I've changed the SPI configuration from this thread: https://devzone.nordicsemi.com/f/nordic-q-a/65072/nrf5430-spi-sample-code

I've changed SPI1 to SPI4 (in nrf5340pdk_nrf5340_cpuapp.overlay, prj.conf and main.c).

It's working, but if I want to set frequency higher than 8MHz it won't let me. 

Code builds and is run but the frequency stays on 8MHz (checked with Saleae Logic Pro 8). I'm changing the frequency in this bit of code:

static const struct spi_config spi_cfg = {
.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB |
SPI_MODE_CPOL | SPI_MODE_CPHA,
.frequency = 10000000,
.slave = 0,
};

As far as I know it should let me change it up to 35 MHz. Am I right?

Thanks, 

Marta

Parents
  • The reason you're only getting 8MHz is because of this function. If you look inside it, it will only allow high frequencies if either CONFIG_SOC_NRF52833 or CONFIG_SOC_NRF52840 is defined, but according to the documentation nRF5340 should also be here. It seems like this is fixed in the master branch, where it looks for SPIM_FREQUENCY_FREQUENCY_M32 instead.

    I guess you can fix this by either using the master branch or adding CONFIG_SOC_NRF5340_CPUAPP to the function.

    Best regards,

    Simon

Reply
  • The reason you're only getting 8MHz is because of this function. If you look inside it, it will only allow high frequencies if either CONFIG_SOC_NRF52833 or CONFIG_SOC_NRF52840 is defined, but according to the documentation nRF5340 should also be here. It seems like this is fixed in the master branch, where it looks for SPIM_FREQUENCY_FREQUENCY_M32 instead.

    I guess you can fix this by either using the master branch or adding CONFIG_SOC_NRF5340_CPUAPP to the function.

    Best regards,

    Simon

Children
Related