UART ISR

Piskun
Posts: 2
Joined: Sun Jan 14, 2018 2:33 pm

UART ISR

Postby Piskun » Sun Jan 14, 2018 3:39 pm

Hello everyone.

I'm starting my adventure with ESP32. Right now I am trying to rewrite some code from STM32. I searched the whole forum, but I did not find the code to use uart hardware interrupt, without fifo queues. I need this to get information about framing error (time critical DMX code, I can`t wait for queue event).

Code: Select all

#define EX_UART_NUM UART_NUM_0
#define BUF_SIZE (1024)
static QueueHandle_t uart0_queue;
uart_isr_handle_t *handle_console;

void deb_ini()
{ 
    uart_config_t uart_config = {
        .baud_rate = 115200,
        .data_bits = UART_DATA_8_BITS,
        .parity = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
    };
    uart_param_config(EX_UART_NUM, &uart_config);
    uart_set_pin(EX_UART_NUM, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
    uart_driver_install(EX_UART_NUM, 0, 0, 0, NULL, 0);
   
    uart_isr_register(EX_UART_NUM,uart_intr_handle,NULL,ESP_INTR_FLAG_LOWMED,handle_console);
 
 uart_enable_rx_intr(EX_UART_NUM);
 }
 
 static void IRAM_ATTR uart_intr_handle()
{
 printf("ISR \n");   
}
After upload code starts normally, printing sommething, but after sending anything to ESP :
abort() was called at PC 0x40081e5d on core 0

Backtrace: 0x40085f94:0x3ffc04f0 0x40086093:0x3ffc0510 0x40081e5d:0x3ffc0530 0x40081f7d:0x3ffc0560 0x400de20e:0x3ffc0580 0x400de269:0x3ffc05c0 0x40082ed2:0x3ffc05e0 0x400818e1:0x3ffc0600

Rebooting...
Second question, how to check where interrupt comes from?

Thank you for any advice.

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: UART ISR

Postby ESP_Sprite » Mon Jan 15, 2018 7:58 am

You cannot run any function that is not specifically specified to be compatible with ISRs in an ISR. Printf is not one of these functions, so it'll crash.

Who is online

Users browsing this forum: Bing [Bot] and 119 guests