This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART Interrupt fault

Hi

nRF52833, SDK16

When using a UARTE interrupt I get a fault which I cannot locate, I have the following code:

static nrfx_uarte_t SER_UART = NRFX_UARTE_INSTANCE(1);
static uint8_t SER_rx_buffer[12];

void SER_UART_Interrupt(nrfx_uarte_event_t const * p_event, void *  p_context)
{
    if (p_event->type == NRFX_UARTE_EVT_RX_DONE)
    {
        //Do something with the data
    }

    //APP_ERROR_CHECK(nrfx_uarte_rx(&SER_UART, SER_rx_buffer, 1));
}

void SER_Init(void)
{
    nrfx_uarte_config_t config = NRFX_UARTE_DEFAULT_CONFIG;
    config.baudrate = NRF_UARTE_BAUDRATE_1200;
    config.hwfc = NRF_UARTE_HWFC_DISABLED;
    config.interrupt_priority = APP_IRQ_PRIORITY_HIGH;
    config.parity = NRF_UARTE_PARITY_EXCLUDED;
    config.pselrxd = IO_UART_RX;
    config.pseltxd = IO_UART_TX;

    APP_ERROR_CHECK(nrfx_uarte_init(&SER_UART, &config, SER_UART_Interrupt));
    APP_ERROR_CHECK(nrfx_uarte_rx(&SER_UART, SER_rx_buffer, 4));
}

When my 4 bytes are recieved, i get a fault and the debugger stops on this line: (no hardfault routine to start but does end up in a hardfault position)

No other information or reason is given to me,

If i remove the interrupt and run the rx in blocking mode, i recieve my data just fine:

void SER_Init(void)
{
    nrfx_uarte_config_t config = NRFX_UARTE_DEFAULT_CONFIG;
    config.baudrate = NRF_UARTE_BAUDRATE_1200;
    config.hwfc = NRF_UARTE_HWFC_DISABLED;
    config.interrupt_priority = APP_IRQ_PRIORITY_HIGH;
    config.parity = NRF_UARTE_PARITY_EXCLUDED;
    config.pselrxd = IO_UART_RX;
    config.pseltxd = IO_UART_TX;

    APP_ERROR_CHECK(nrfx_uarte_init(&SER_UART, &config, NULL));
    APP_ERROR_CHECK(nrfx_uarte_rx(&SER_UART, SER_rx_buffer, 4));
    
    //this works in clocking mode, and i now have my data in SER_rx_buffer
}

I have tried different interrupt priorities but none seem to make a difference

Can anyone suggest why my interrupt is not correct and the debugger is stopping?

Many thanks

Related