0

I have been using the Ticker to blink a led successfully. However, now I am fetching temperature from a DS18B20 in the main loop (which is using the OneWire library) and the blink is now erratic.

Is the Ticker suspended by the DallasTemperature/OneWire library?

It this suspending interrupts or something?

Maybe using the same interrupt?

2

Ticker does not interrupt your code. It is a OS-timer and will call your function once the time is elapsed.

The Tiker callback can be interrupted by a "real" interrupt or another Task with higher priority and does not provide any reliability - it will just be called.

A solution (not the best) would be to disable manually all interrupts, if you can't solve it in another way.

If you just want a blinking led, you should use a Timer interrupt as your callback is short and fast. Maybe with the ICACHE_RAM_ATTR attribute.

| improve this answer | |
  • OS-timer means it's get called after the loop() or during a yield() is that correct? – HixField Dec 31 '19 at 11:43
  • @HixField sorry, I didn't wrote it correctly. It is called during the loop. It will "interrupt" the loop, but not another interrupt and not an important operation (like an access to the SPIFFS). It will for example executed once the SPIFFS-transaction is over or once the SPI/OneWire-interrupt is over. (A HW-Timer can interrupt also a SPIFFS-access). – Adriano Dec 31 '19 at 11:45
  • Hmm ok. It is strange though because I just changed my DS18B20 implementation to a non blocking one (in the loop) and now everything is working fine. I checked the DS18B20 lib and the only thing it does to "block" was a while(...) {} (without any yield). I do have the impression that the ticker can be inrerrupted by blocking functions... – HixField Dec 31 '19 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.