Disable Interrupts for Legacy Serial Write
Posted: Fri Feb 09, 2024 3:07 pm
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 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?
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