Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By urbanze
#67644 Hi again guys :). Now, I need to know why os_timer can't call an function inside of while without yield(). I search about system task priority but don't find good news.

In MCU world, like arduino, timer (hardware) have max priority in system, then, if MCU is locked inside of any loop, timer go to function without problems.

But in ESP, OS_TIMER don't make this, if MCU is locked inside of any loop, os_timer can't go to a function WITHOUT yield's or delay's.

How can i change os_timer to max priority (if have)? I testing hardware watchdog and need to feed her, even MCU inside of loop without yield.

I know os_timer is based on software, but can change this situation?

Image of testing code.

Image


Hardware watchdog has ~8 seconds to reset MCU, then, I put timer to feed before 8 sec. I put an while to lock MCU inside of loop. Hardware Watchdog DON'T fed with yield or delay, like Software Watchdog.

Loop with yield, os_timer work's and MCU not reset. Because yield processes some task os system I think.
Loop without yield, os_timer doens't work, then HW WDT reset.

OK, OK. After explications, I need to UP task priority of os_timer without put yield in all of 2500 lines.
User avatar
By urbanze
#67681
philbowles wrote:I'm not sure I understand what you are trying to do. If your code is locked in a tight loop, of course no other code can run, unless it is initiated by an external interrupt. This is why sometimes you have to yield() - to allow the ESP8266 WiFi code to run. If you "starve" that code for too long (I think > 20ms) you will get a wdt reset.

I'm not sure its possible to change the priority- even if it was, that is not the problem. The problem is that the WDT fired when your code is taking too long. So, you need to look at your code. You maybe need to restructure it so that it is asynchronous (i.e. does not make any "blocking" calls).

If you DO end up putting in hundreds of yields, then this is a message that your code is either very wrong / badly structured / unable to do what you want it to do unless it also allows for the "concurrent" esp8266 "background" tasks to run.


Yes I agree with you. I know of these background problems in ESP, but as it has the RTOS version that is based on task priority, maybe to change something. The code that I will implement this HW WDT, has a function that sometimes by the size of JSON, can cause the system to restart (yes, I have already yielded). I will deactivate the SW WDT which has a shorter time than the HW WDT, and will activate it before the time runs out. Let's see if it works in practice...