This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SPI master doesn't call spi_event_handler when transferred.

Hi!

I made same code for SDK15 and it works. Now I want to rebuild project on the new SDK17.0.2 and same part of code doesn't work with SPI master.

For notice- doesn't work native example 

...examples\peripheral\spi\

And I made on the my project all settings like it was on SDK15 and can't call interrupt spi_event_handler.

my settings:

#define SPI_INSTANCE  0 /**< SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**< SPI instance. */
static volatile bool spi_xfer_done;  /**< Flag used to indicate that SPI instance completed the transfer. */

void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    spi_xfer_done = true;
//    NRF_LOG_INFO("Transfer completed.");
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(" Received:");
//        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}

static __INLINE uint8_t lis3dh_spi_read_write(const uint8_t reg, const uint8_t data)
{
//	uint8_t rx_buffer[2], tx_buffer[] = { reg, data };
    m_tx_buf [0] = reg;
    m_tx_buf [1] = data;
    
    spi_xfer_done = false;
    
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));
    
    while (!spi_xfer_done)
    {
        __WFE();
    }
	return m_rx_buf[1];
}

uint8_t lis3dh_read(const uint8_t reg) 
{		
	return lis3dh_spi_read_write(reg | LIS3DH_READ_MSK, 0xAA);	
}

void lis3dh_write(const uint8_t reg, const uint8_t data) 
{
	lis3dh_spi_read_write(reg | LIS3DH_WRITE_MSK, data);	
}
    
void lis3dh_init(void)
{
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = 7;
    spi_config.miso_pin = 8;
    spi_config.mosi_pin = 9;
    spi_config.sck_pin  = 10;

    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));

	lis3dh_write(CTRL_REG1, 0x2F); 		
}

What I make wrong?

Parents
  • Okay, I'm not able to see why you should have an issue with any of this. And it's strange that it works on one SDK but not the other. Can you show me the schematics on your custom board so I can do a quick review of it. You're sure you're not using P0.09 and P0.10 for SPI communication on the custom board right? Because these are configured as NFC pins by default.

    Best regards,

    Simon

  • No, I use these pins

        spi_config.ss_pin   = 7;
        spi_config.miso_pin = 8;
        spi_config.mosi_pin = 9;
        spi_config.sck_pin  = 10;

    and 9 and 10 too. But strange that it works on the SDK15. 

    Ok, in the SDK17 where should I disable 9 and 10 pins from NFC?

    Scheme next:

Reply
  • No, I use these pins

        spi_config.ss_pin   = 7;
        spi_config.miso_pin = 8;
        spi_config.mosi_pin = 9;
        spi_config.sck_pin  = 10;

    and 9 and 10 too. But strange that it works on the SDK15. 

    Ok, in the SDK17 where should I disable 9 and 10 pins from NFC?

    Scheme next:

Children
No Data
Related