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

nrf52 nrf_drv_spi_transfer event callback not being called?

Hi everyone,

I'm integrating the spi_master_with_spi_slave example into our firmware; however, I'm not seeing the event callback I registered being called. I'm verifying via a Saleae Logic Analyzer that data is coming out of the MOSI line.

I'm currently setting up breakpoints (in Keil) at 2 points: 1) the call to nrf_drv_spi_transfer and 2) the event callback itself. I'm able to break at the transfer, but not within the event handler.

Things I've tried:

  1. Turned off optimizations

  2. Modifying a volatile variable within the handler

  3. implementing a while(1) within the handler

None of these tests pointed to the handler being called.

Any thoughts on the matter?

Thank you,

Aadu

  • Hi

    Are you configuring connecting two devices, i.e. one as spi master and the other as spi slave? Or are you connecting the master in a loopback?

    I dont realize what SDK you are using or what nRF52832 hardware revision you have, but since you mention the spi_master_with_spi_slave, I assume you are using nRF52 SDK 0.9.2 and have Engineering A revision which is compatible with nRF52 SDK 0.9.2. Am I right or wrong?

    What about the CSN line, does the SPI master set it high at the end of the transmission to end the transaction. When CSN line is set high, that should actually trigger the event on the slave side.

    The two SDK examples, spi_master_with_spi_slave should work together. If you can run them on two boards and record the transmission on the SPI lines with your logical analyzer, then you could see how a successful transmission looks like. You could then compare that to the transmission that is not working and perhaps spot what is missing.

    You could also set a breakpoint where the interrupt is received from the hardware in the nrf_drv_spi.c file, i.e. in the SPI0_IRQ_HANDLER if you are using SPI0 peripheral.

    Make sure the mode settings match between spi master and spi slave in the spi configuration, i.e.

    	typedef enum
    	{
    			NRF_DRV_SPI_MODE_0 = NRF_SPI_MODE_0, ///< SCK active high, sample on leading edge of clock.
    			NRF_DRV_SPI_MODE_1 = NRF_SPI_MODE_1, ///< SCK active high, sample on trailing edge of clock.
    			NRF_DRV_SPI_MODE_2 = NRF_SPI_MODE_2, ///< SCK active low, sample on leading edge of clock.
    			NRF_DRV_SPI_MODE_3 = NRF_SPI_MODE_3  ///< SCK active low, sample on trailing edge of clock.
    	} nrf_drv_spi_mode_t;
    

    The slave may need a little delay between SCN line set until start of transmission, up to 4us

Related