Hello,
I'm currently developing an application using an NRF52832 and SDK15 (SD 6.0.0). I have an issue that causes an UART overrun during some flash operations and it somehow crashes the application. It doesn't throw an error, it doesn't hang at a specific place and it doesn't reset, but it somehow doesn't do anything either, i.e. it terminates any connections, it stops advertising, it doesn't output anything. Nevertheless, if I halt and run using JLink I can see the program counter moving both in the SD and APP memory regions.
I assume the UART overrun is caused because of the CPU being blocked by the flash writes, not being able to process the interrupts. That is according to the documentation of sd_flash_write in the infocenter. However, the UART overrun is handled, I've seen it many times before in my application and it recovers from it. That is not the case this time.
I am using the experimental FDS library to handle writing to flash. I am handling all the errors that come out the calls to the FDS API.
Thanks for your help as always!
EDIT: I think the flash doesn't have anything to do with the crash. I just saw the same behavior with another overrun on BLE connection where flash was not involved at all.
I don't have flow control in my application due to hardware limitations (RTS/CTS pins on the other end are already in use for another purpose).
For reference, this is how I'm handling the overrun:
void uart_error_handler(const nrfx_uart_t * instance, nrfx_uart_event_t const * p_event) { uint32_t error_mask = p_event->data.error.error_mask; if (error_mask & UART_ERRORSRC_OVERRUN_Msk) { debug_error("UART overrun"); uint8_t num_bytes = p_event->data.error.rxtx.bytes; for (uint8_t i = 0; i < num_bytes; i++) { // Empty the buffer uint8_t tmp = nrf_uart_rxd_get(instance->p_reg); UNUSED_VARIABLE(tmp); } } if (error_mask & UART_ERRORSRC_FRAMING_Msk) { debug_error("UART framing error"); } uart_reinit(instance); } void uart_reinit(const nrfx_uart_t * instance) { nrfx_uart_uninit(instance); uint32_t err_code = nrfx_uart_init(instance, &uart_config, uart_event_handler); nrf_gpio_cfg( unleashed_uart_config.pseltxd, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_H0D1, NRF_GPIO_PIN_NOSENSE ); nrf_gpio_cfg( unleashed_uart_config.pselrxd, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_H0D1, NRF_GPIO_PIN_NOSENSE ); if (err_code != NRF_SUCCESS) { debug_error("Failed to reinitialize UART"); } nrfx_uart_rx_enable(instance); debug_line("UART reinitialized\n"); }
EDIT 2: It seems the reinitialization routine has a problem. I commented out and it kind of works. I'll test it some more and I'll update.