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

Parents
  • Hi

    I am still very stuck with this problem, I have removed everything from my project and reduced it to the absolute minimum and still get the same problem - as soon as a single byte is received, I get a hardfault when the interrupt should be generated.

    I have attached the project in the hope someone could point out what is not correct.

    The pare is a nrf52833, so the pca directory name is not correct, but everything has been changed from a configuration point of view and the firmware is running on a 52833DK.

    It looks to be an interrupt vector issue but I can't see where I can change it

    Thanks for any help

    CP900.zip

  • Hi,

    I don't see any problems in your code. You can look at call stack window to see where hard fault is coming from (make sure to compile project with disabled optimization). Even better way is to include SDK hardfault handling library (components\libraries\hardfault) into your project.

  • Thanks,

    After including the hard fault handler I get

    <error> hardfault: HARD FAULT at 0x00000000
    <error> hardfault:   R0:  0x000000E0  R1:  0x00000000  R2:  0x0EB6072E  R3:  0xCAFEBABE
    <error> hardfault:   R12: 0x20004AFA  LR:  0xFFFFFFF9  PSR: 0x00000038
    <error> hardfault: Cause: The processor has attempted to execute an instruction that makes illegal use of the EPSR.

    Is this something I have done wrong?

Reply
  • Thanks,

    After including the hard fault handler I get

    <error> hardfault: HARD FAULT at 0x00000000
    <error> hardfault:   R0:  0x000000E0  R1:  0x00000000  R2:  0x0EB6072E  R3:  0xCAFEBABE
    <error> hardfault:   R12: 0x20004AFA  LR:  0xFFFFFFF9  PSR: 0x00000038
    <error> hardfault: Cause: The processor has attempted to execute an instruction that makes illegal use of the EPSR.

    Is this something I have done wrong?

Children
No Data
Related