[Solved]UART rx ISR not working
Posted: Sat May 05, 2018 6:53 pm
Hi,
i am trying to work with UART on esp32, using esp-idf. i modified UART event sample code so that i can register UART IRQ routine and receive data directly, below is modified code,
i got this code from this FORUM, however mine is not working, i don't receive anything, as you can see i have written UART_Write on invoking of interrupt routine, but it doesnt work.
i would like to know whats wrong with this code.
Thanks Sushant
i am trying to work with UART on esp32, using esp-idf. i modified UART event sample code so that i can register UART IRQ routine and receive data directly, below is modified code,
Code: Select all
void app_main()
{
esp_log_level_set(TAG, ESP_LOG_INFO);
/* Configure parameters of an UART driver,
* communication pins and install the driver */
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);
//Set UART log level
esp_log_level_set(TAG, ESP_LOG_INFO);
//Set UART pins (using UART0 default pins ie no changes.)
uart_set_pin(EX_UART_NUM, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
//Install UART driver, and get the queue.
uart_driver_install(EX_UART_NUM, BUF_SIZE * 2, 0, 0, NULL, 0);
// //Set uart pattern detect function.
// uart_enable_pattern_det_intr(EX_UART_NUM, '+', PATTERN_CHR_NUM, 10000, 10, 10);
// //Reset the pattern queue length to record at most 20 pattern positions.
// uart_pattern_queue_reset(EX_UART_NUM, 20);
// Register ISR routine for RX interrupt
uart_isr_register(EX_UART_NUM,uart_intr_handle, NULL, ESP_INTR_FLAG_LOWMED, handle_console);
uart_enable_rx_intr(EX_UART_NUM);
//Create a task to handler UART event from ISR
//xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, 12, NULL);
}
// --- UART ISR Routine
static void IRAM_ATTR uart_intr_handle()
{
uart_write_bytes(EX_UART_NUM, (const char*) "RX Done", 7);
}
i would like to know whats wrong with this code.
Thanks Sushant