Page 1 of 1

Disable Interrupts for Legacy Serial Write

Posted: Fri Feb 09, 2024 3:07 pm
by seb101
I need to send data to a very simple non-standard serial interface on a remote device, it is not UART compatible, so needs to be sent by driving a TX pin with precise timing from the CPU. It is a fixed length data frame, 9 data bytes and the checksum. I have this working fine, except for when I enable other functions on the ESP, like the WebSockets interface, as events messages received on the WebSocket cause interrupts that can (and often do) halt the processing of the serial write mid-frame, causing the frame to fail to the receiver.

How do I protect the execution of the serial write routine so that nothing can interrupt it while it's transmitting a frame?

I have looked at

Code: Select all

taskENTER_CRITICAL
however this seems overkill as it prevents interrupts occuring on both cores, is there a function to just disable interrupts on the current execution core?

Re: Disable Interrupts for Legacy Serial Write

Posted: Sat Feb 10, 2024 6:22 am
by ESP_Sprite
Easier to just use hardware; e.g. look at the RMT peripheral.