Dear Nordic,
I'm developing an application using the NUS service en SPIM peripheral. Both of these work correctly independently. Now I'm trying to start an SPI transaction triggered by NUS, where I receive data on NUS and send them to SPI. This part is still functional.
After the SPI transaction, the code waits for the spi_transfer_done event. This event however never occurs. See the code snippet below.
I think this is due to the fact that I call the SPI transfer from the NUS data handler which has a higher interrupt priority. I have not been able to find the interrupt priority of the NUS data handler, but I have tried setting the SPIM interrupt priority from 7 all the way to 2.
What would be a workaround to be able to receive the SPIM event, or the correct way to solve this?
static void register_read(max3421e_host_registers_t register_to_access, int rx_length) { memset(m_tx_buf, 0, tx_buf_length); memset(m_rx_buf, 0, rx_buf_length); *p_spi_xfer_done = false; m_tx_buf[0] = command_byte_set(register_to_access, read); nrfx_spim_xfer_desc_t transfer_descriptor; transfer_descriptor.p_tx_buffer = m_tx_buf; transfer_descriptor.tx_length = 1; transfer_descriptor.p_rx_buffer = m_rx_buf; transfer_descriptor.rx_length = rx_length + 1; APP_ERROR_CHECK(nrfx_spim_xfer(p_spim_instance, &transfer_descriptor, 0)); while (!*p_spi_xfer_done) //This interrupt isn't being handled, thus an infinite loop { __WFE(); } }
Kind regards,
Kevin