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

APP_UART called during an interruption not working properly.

Dear community,

I am developing a firmware using SDK 16.0.0 which handles interruptions from an accelerometer and a timer.

I've built on top of APP_UART lib a set of functions for printing to the console as well as WifI module.

After configuring the interruptions for the GPIOTE coming from the accelerometer and the timer, I've tried to print some debug info through APP_UART and figured out that it only prints 1 char when it is called from a function handler.

void _print_uart(char *str, const app_uart_comm_params_t *param)
{
    size_t len = strlen(str);
    uint32_t err_code;

    APP_UART_FIFO_INIT(param, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, _uart_error_handle, APP_IRQ_PRIORITY_LOWEST, err_code);
    APP_ERROR_CHECK(err_code);

    for (size_t i = 0; i < len; i++)
    {
        while (app_uart_put(str[i]) != NRF_SUCCESS);
    }

    nrf_delay_ms(10);

    app_uart_close();
}

I've changed the IRQ  priorities and tried some priorities around it but the behaviour keeps the same.

This might not happen in the real case scenario where no console output exists, but since I have no clue of what is happening, this can represent a problem when sending/receiving info to/from the Wifi (even though I can turn of the interruptions during this process) but can also cause some problems with the GPIOTE interruption as well.

A simple test scenario I've created using nrfx_timer looks like this:

void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{

    switch (event_type)
    {
        case NRF_TIMER_EVENT_COMPARE0:
            nrf_gpio_pin_toggle(LED_3);
            print_debug("U\r\n");
            break;

        default:
            //Do nothing.
            break;
    }
}

Where the handler is triggered every 500ms.

Parents Reply Children
Related