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

SPI speed when using SDHC via SPI in Zephyr

I'm using the Nordic nRF52840-DK board to breadboard an SDHC card interface in Zephyr using SPI. I have it doing "basic" operations, but am trying to reconcile what I'm physically seeing versus what is documented and what I see in the code.

I was hoping to run the SPI at 8 MHz, so I included a statement in the .overlay file: clock-frequency = <8000000>; (in the SPI specification).

I also put the statement: spi-max-frequency = <8000000>; (in the specification of the SDcard sub-device (under the SPI specification)).

The Zephyr SDHC documentation page seems to imply that the spi-max-frequency parameter is the SPI running frequency applied after initialization.

But it appears that hardcoded into disk_access_spi_sdhc.c are statements that assign the speed to be 400 KHz during initialization, then 4 MHz for later operations.

But then looking at the waveform captured by a logic analyzer, it appears that the SCK signal is actually running at around 250 KHz.

What am I missing?

Thanks!

P.S.   I submitted this as an issue at the Zephyr Git website about a week ago, but there has been no response.   I thought I'd also submit here since the underlying hardware is Nordic and I'm using NCS v1.5.0 and the Zephyr code included there...

Parents
  • Hi,

     

    But it appears that hardcoded into disk_access_spi_sdhc.c are statements that assign the speed to be 400 KHz during initialization, then 4 MHz for later operations.

    But then looking at the waveform captured by a logic analyzer, it appears that the SCK signal is actually running at around 250 KHz.

    What am I missing?

    Due to this check, the spim driver does not allow you to reconfigure the frequency after it has been initially set:

    https://github.com/nrfconnect/sdk-zephyr/blob/master/drivers/spi/spi_nrfx_spim.c#L112-L114

    I've inputted this as a improvement internally; to allow the spim-port to change frequency. 

    I submitted this as an issue at the Zephyr Git website about a week ago, but there has been no response.   I thought I'd also submit here since the underlying hardware is Nordic and I'm using NCS v1.5.0 and the Zephyr code included there...

    Its this one, right? https://github.com/zephyrproject-rtos/zephyr/issues/32996

    I have added this to the internal jira that I registered.

     

    Kind regards,

    Håkon

  • Yes, that is the github/zephyrproject issue entry.     It seems that the Zephyr SPI driver should have characteristics much like the nRF5 SDK driver (where each transaction can have its own configuration, since different peripherals (which may share an SPI instance) have different speed capabilites.    This is also true for the TWIM/I2C device driver.)  I had to spin my own I2C driver since the Zephyr version doesn't seem to have the features provided for by the nRF5 SDK Libraries (ability to run TWIM/I2C transactions in the background and get completion interrupts).

Reply
  • Yes, that is the github/zephyrproject issue entry.     It seems that the Zephyr SPI driver should have characteristics much like the nRF5 SDK driver (where each transaction can have its own configuration, since different peripherals (which may share an SPI instance) have different speed capabilites.    This is also true for the TWIM/I2C device driver.)  I had to spin my own I2C driver since the Zephyr version doesn't seem to have the features provided for by the nRF5 SDK Libraries (ability to run TWIM/I2C transactions in the background and get completion interrupts).

Children
No Data
Related