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
  • Hi Mikhail

    How does your custom_board file look in SDK 15 and 17? When moving to newer SDK versions it's important to follow the migration guides we provide with each SDK release. Please check out the migration guide for SDK v16 and SDK v17 and make sure you have made any necessary changes there.

    Can you also provide some details as to how exactly the SDK 17 project is not working on your end?

    Best regards,

    Simon

  • Hi!

    First I want to notice that your site doesn't work correctly under chrome. There are no reply button- check it. Under explorer works fine.

    Regarding migration- I just created a new project with SPI on the SDK17 and just added some functions for work with my SPI device LIS3DH. And I didn't get callback.

  • Hi

    Mikhail said:
    I didn't get callback.

    What callback are you not seeing, and what do you expect to see?

    Yes, DevZone is having some issues unfortunately, we're aware of it and are currently working to resolve it. Workarounds when this occurs in Chrome is to first try deleting your cookies, and if you still don't see a reply button try refreshing the page and it should show up.

    Best regards,

    Simon

Reply
  • Hi

    Mikhail said:
    I didn't get callback.

    What callback are you not seeing, and what do you expect to see?

    Yes, DevZone is having some issues unfortunately, we're aware of it and are currently working to resolve it. Workarounds when this occurs in Chrome is to first try deleting your cookies, and if you still don't see a reply button try refreshing the page and it should show up.

    Best regards,

    Simon

Children
Related