Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By skettlitz
#74690 I need to do data collection at fixed intervals. For this I need an ISR on Timer1. Using the "os timer" or the "loop" is not reliable enough for this. Both alternatives would avoid any WiFi hangs but don't collect the data properly.

This interrupt for itself seems to work very reliably. I've checked by toggling a pin and recording it on the oscilloscope. I trigger the interrupt every 1000 us for this test. The remaining jitter is down to +-3 us. This seems good enough for data collection. The interrupt function itself seems to be 100% reliable even when pages are served or the WiFi starts to hang.

I set up a SoftAP and serve a page via ESP8266WebServer. I serve a big page for testing and call "yield()" repeatedly inside the http handler. When the Timer1 interrupt is disabled, this also works very reliably. I've reloaded the page a thousand times without problems.

BUT

With all three Timer1 + SoftAP + Webserver enabled I get the following situation:

Case A: Interrupt is limited to 10 us.
  • Everything is fine.

Case B: Interrupt takes 600 us.
  • When not serving pages everything seems fine.
  • When serving pages it works a few reloads and then hangs.
  • The ESP stops serving pages and also stops answering pings at that time.
  • After a reset it works again until the page is loaded a few times.

I have tried to find the answers to these questions but didn't find anything useful. A dozen people must have run into the same problems but I didn't find any.
  • Is the SoftAP mode not compatible with interrupts?
  • Is there a maximum time duration for ISR where they are safe? (10 us seems safe but is too short for me, 600 us is unstable.)
  • Is there a maximum processing percentage reserved for interrupt routines? (E.g. 30%)
  • Do I need to configure something so it stays stable?
User avatar
By skettlitz
#74761 For the test I switch on a GPIO pin at the start and switch it off at the end of the interrupt. I write to GPOC and GPOS directly instead of using "digitalWrite" for this. In between I have a NOP loop for creating the desired delay. Nothing else.

In the future I want to do OneWire/I2C/SPI communication in the interrupt. These things need to be uninterrupted.

Yes, I need good timing and low jitter to get a good signal. Currently, I use 1 kHz sampling rate. The jitter/delay you get with the loop function or the os timers is not good enough.