Disable Interrupts for Legacy Serial Write

seb101
Posts: 1
Joined: Fri Feb 09, 2024 2:19 pm

Disable Interrupts for Legacy Serial Write

Postby seb101 » 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

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?

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

Re: Disable Interrupts for Legacy Serial Write

Postby ESP_Sprite » Sat Feb 10, 2024 6:22 am

Easier to just use hardware; e.g. look at the RMT peripheral.

Who is online

Users browsing this forum: No registered users and 53 guests