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 the description in NRF52 datasheet V1.0 20.2.2 NFC antenna pins Two physical pins can be configured either as NFC antenna pins (factory default), or as GPIOs P0.09 and P0.10. When configured as NFC antenna pins, the GPIOs on those pins will automatically be set to DISABLE state and a protection circuit will be enabled preventing the chip from being damaged in the presence of a strong NFC field. The protection circuit will short the two pins together if voltage difference exceeds approximately 2. It seems there are additional settings needed be configured, but I still have no idea about it.. BTW, this symptom happen too if I assign gpio10 to clock.

    Thanks..

Reply
  • Hi Peter: Here is the description in NRF52 datasheet V1.0 20.2.2 NFC antenna pins Two physical pins can be configured either as NFC antenna pins (factory default), or as GPIOs P0.09 and P0.10. When configured as NFC antenna pins, the GPIOs on those pins will automatically be set to DISABLE state and a protection circuit will be enabled preventing the chip from being damaged in the presence of a strong NFC field. The protection circuit will short the two pins together if voltage difference exceeds approximately 2. It seems there are additional settings needed be configured, but I still have no idea about it.. BTW, this symptom happen too if I assign gpio10 to clock.

    Thanks..

Children
No Data
Related