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: I just modified the configuration of Pins. And the handler can be triggered with same configuration on PCA1036 but not triggered on my HW. However, if I just changed the pin number of clock from 9 to the original pin number, it work both on my HW and PC10036. I have no idea about why pin9 not work??

    I just refer sample code to set the initial value to rx buffer, no special usage.

    I set breakpoints in the handler ant it is not trapped.

    Thanks...

Reply
  • Hi Peter: I just modified the configuration of Pins. And the handler can be triggered with same configuration on PCA1036 but not triggered on my HW. However, if I just changed the pin number of clock from 9 to the original pin number, it work both on my HW and PC10036. I have no idea about why pin9 not work??

    I just refer sample code to set the initial value to rx buffer, no special usage.

    I set breakpoints in the handler ant it is not trapped.

    Thanks...

Children
No Data
Related