ESP32中断Bug特性

浮点运算

在中断内进行浮点运算会自动复位。在官方文档可以查到。
官方文档描述如下:
ESP-IDF FreeRTOS implements Lazy Context Switching for FPUs. In other words, the state of a core’s FPU registers are not immediately saved when a context switch occurs. Therefore, tasks that utilize float must be pinned to a particular core upon creation. If not, ESP-IDF FreeRTOS will automatically pin the task in question to whichever core the task was running on upon the task’s first use of float. Likewise due to Lazy Context Switching, only interrupt service routines of lowest priority (that is it the Level 1) can use float, higher priority interrupts do not support FPU usage.

ESP32 does not support hardware acceleration for double precision floating point arithmetic (double). Instead double is implemented via software hence the behavioral restrictions with regards to float do not apply to double. Note that due to the lack of hardware acceleration, double operations may consume significantly larger amount of CPU time in comparison to float.

串口中断

触发串口中断后报错,控制台显示中断看门狗超时,没有及时喂狗。
乐鑫论坛找到相关解决方法。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
static void IRAM_ATTR uart_isr_callback_1(void *arg) 
{
uart_flush(UART_NUM_1);
uart_clear_intr_status(UART_NUM_1, UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
}

void open_uart_isr(uart_port_t UART_NUM)
{
uart_isr_free(UART_NUM);
if(UART_NUM == UART_NUM_1)
{
uart_isr_register(UART_NUM_1, uart_isr_callback_1, NULL, ESP_INTR_FLAG_IRAM, NULL);
}
else if(UART_NUM == UART_NUM_2)
{
uart_isr_register(UART_NUM_2, uart_isr_callback_2, NULL, ESP_INTR_FLAG_IRAM, NULL);
}
uart_enable_rx_intr(UART_NUM);
}