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

spi_event_handler is not triggered

Hi all: Below is my source code for SPI master. However, the handler is not triggered ... Is any setting I missed?

Thanks...

void spi_event_handler(nrf_drv_spi_evt_t const * p_event)
{
    spi_xfer_done = true;
    NRF_LOG_PRINTF(" Transfer completed.\r\n");
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_PRINTF(" Received: %s\r\n",m_rx_buf);
    }
}

int main(void)
{
    //LEDS_CONFIGURE(BSP_LED_0_MASK);
    //LEDS_OFF(BSP_LED_0_MASK);

    //APP_ERROR_CHECK(NRF_LOG_INIT());
    //NRF_LOG_PRINTF("SPI example\r\n");

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG(SPI_INSTANCE);
    spi_config.ss_pin = 7;
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler));

    while(1)
    {
        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0xa5, 3);
        spi_xfer_done = false;
         

        APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, 0));

        while (!spi_xfer_done)
        {
            __WFE();
        }
        //APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));
  
        //LEDS_INVERT(BSP_LED_0_MASK);
        nrf_delay_ms(200);
    }
}
Parents
  • Hi Peter: Here is my understandings and please correct me if any item is incorrect.

    1. The handler should always be triggered as long as the clock is generated to transfer data , no matter the data if the data is received by slave . Is it right?
    2. if item 1 is true, the handler should be always be triggered as long as I set the pin number for clock? Is it right?
    3. If both of item 1 and 2 are correct, Can I based on these conclusions to convince HW engineer to check his design?

    Thanks..

Reply
  • Hi Peter: Here is my understandings and please correct me if any item is incorrect.

    1. The handler should always be triggered as long as the clock is generated to transfer data , no matter the data if the data is received by slave . Is it right?
    2. if item 1 is true, the handler should be always be triggered as long as I set the pin number for clock? Is it right?
    3. If both of item 1 and 2 are correct, Can I based on these conclusions to convince HW engineer to check his design?

    Thanks..

Children
No Data
Related