Chat freely about anything...

User avatar
By Lotus
#30136 Hello,

I still haven't been able to get this answered:

Is there a way for instance to deterministically set a GPIO output level e.g. 10 times a second without any interruptions?
User avatar
By dkinzer
#30139
Lotus wrote:Is there a way for instance to deterministically set a GPIO output level e.g. 10 times a second without any interruptions?
The short answer is "no". The longer answer is more complicated.

The ESP has non-maskable interrupts. I don't know what part of the system uses them - perhaps the network interface. At any rate, unless you prevent non-maskable interrupts from occurring you will always have a possibility that your exquisitely planned timing will be disrupted. I have seen discussion of a technique to disable non-maskable interrupts but I haven't used it.

That said, you can still get pretty good accuracy and repeatability by configuring the RTC Timer1 to generate a periodic interrupt and then use the direct port manipulation registers to set/clear bits in the ISR. There will still be some interrupt latency that will introduce jitter in your timing but, depending on the application, it may be acceptable. If you look at the software PWM example code in earlier SDKs (v1.01 b2 and earlier) you can see how to use the RTC timer and how to manipulate I/O pins in the ISR. There will be a lot of code to cut away but the essence of what you need is there.