Hello everyone,
I have a nrf52832 (SDK v15.2.0) that is connected to a tablet via BLE. However, if I have several SPI transfers one after another, the BLE suddenly disconnects. It doesn't make a difference neither if I use the DMA or if I'm blocking. The priority of the SPI interrupts is also very low and equal to 6. I need to mention that all the SPI transfers are done in the function I schedule once (which is called do_all_the_xfers() here). So it looks the following:
static void do_all_the_xfers(void * data, uint16_t len) { for(uint32_t i = 0; i < 4294967295; i++) { status = pltf_spim_xfer2(); if(status != NO_ERROR) return; } }
While pltf_spim_xfer2() looks like this:
static const nrfx_spi_t spi = NRFX_SPI_INSTANCE(FLASH_SPI_INSTANCE); bool spi_xfer_done = false; void spi_event_handler(nrfx_spi_evt_t const * p_event, void * p_context) { spi_xfer_done = true; } status_t pltf_spim_xfer2(void) { uint32_t err_code, flags; flags = 0; spi_xfer_done = false; nrfx_spi_xfer_desc_t xfer; char read_id_cmd = 0x9F; char rx_buf[3]; xfer.p_tx_buffer = &read_id_cmd; xfer.tx_length = 1; xfer.p_rx_buffer = NULL; xfer.rx_length = 0; nrf_gpio_pin_clear(FLASH_SPI_SS_PIN); err_code = nrfx_spi_xfer(&spi, &xfer, flags); if(err_code != 0) { NRF_LOG_INFO("err_code: %i", err_code); NRF_LOG_FLUSH(); } while(!spi_xfer_done){}; spi_xfer_done = false; xfer.p_tx_buffer = NULL; xfer.tx_length = 0; xfer.p_rx_buffer = rx_buf; xfer.rx_length = 3; nrf_gpio_pin_clear(FLASH_SPI_SS_PIN); err_code = nrfx_spi_xfer(&spi, &xfer, flags); if(err_code != 0) { NRF_LOG_INFO("err_code: %i", err_code); NRF_LOG_FLUSH(); } while(!spi_xfer_done){}; return NO_ERROR; }
Therefore, the scheduler doesn't go back to the main loop until its done with all the transfers. Nevertheless, according to my understanding the Bluetooth has such a high priority that even in case of a while(1) loop, its interrupts are handled. So what could be the problem?
Thanks in advance!