This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Changing SPI frequency

Hi, We're using the SPI to communicate with a device that, when powered up, supports only up to 3Mbps SPI frequency , but after a while can work with higher frequencies. Is it possible to change the SPI Master frequency on the fly with the nRF51822? I've tried changing the FREQUENCY field in the struct (from 2Mbps to 4Mbps), but it seems to have no effect.

Thanks!

Parents
  • Hi

    You can change the frequency by writing to the struct with e.g. :

     spi_config.SPI_Freq = SPI_FREQUENCY_FREQUENCY_M4;
    

    However, if you would like to change the SPI frequency on the fly, you can do that by writing directly to the frequency register of the SPI module that you are using, i.e.

    NRF_SPI0->FREQUENCY = SPI_FREQUENCY_FREQUENCY_M4;
    

    Make sure to change the frequency only when the SPI is not transmitting/receiving.

  • Thanks for the update. Basically, apart from the frequency, we don't need any other configuration change. The SPI close/open procedure resets a lot of the other parameters. Will it be enough to just disable and re-enable the SPI through p_nrf_spi->ENABLE, or are there other steps that needs to be taken? We want to shorten this process to the bare minimum needed for the frequency change.

Reply
  • Thanks for the update. Basically, apart from the frequency, we don't need any other configuration change. The SPI close/open procedure resets a lot of the other parameters. Will it be enough to just disable and re-enable the SPI through p_nrf_spi->ENABLE, or are there other steps that needs to be taken? We want to shorten this process to the bare minimum needed for the frequency change.

Children
No Data
Related