Jul 14, 2021 Replies: 6 If it might have occured also to you to get a "Soft WDT Reset" error in an ESP8266 project then here is why this had happened and how to correct it: ESP8266 runs several background tasks that check the state of the integrated circuit (f.e. maintain WiFi connection and other stuff) and has two watchdogs one software based and one hardware based that want to give priority to the state checking. For more information please check this URL: My ESP crashes running some code. How to troubleshoot it? — ESP8266 Arduino Core documentation In order to avoid triggering the WDT errors you will need to interrupt slightly (and repeatedly in each loop) long running procedures either with a Delay(1) command or with the yield() function. I have not found this function in the B4R available commands so I created an InLine function that can be called this way: [CODE lang="b4x" title="yield() function in B4R"]RunNative("yld", Null) #if C void yld(B4R::Object* o){ yield(); } #End If [/CODE] Click to expand...
If it might have occured also to you to get a "Soft WDT Reset" error in an ESP8266 project then here is why this had happened and how to correct it: ESP8266 runs several background tasks that check the state of the integrated circuit (f.e. maintain WiFi connection and other stuff) and has two watchdogs one software based and one hardware based that want to give priority to the state checking. For more information please check this URL: My ESP crashes running some code. How to troubleshoot it? — ESP8266 Arduino Core documentation In order to avoid triggering the WDT errors you will need to interrupt slightly (and repeatedly in each loop) long running procedures either with a Delay(1) command or with the yield() function. I have not found this function in the B4R available commands so I created an InLine function that can be called this way: [CODE lang="b4x" title="yield() function in B4R"]RunNative("yld", Null) #if C void yld(B4R::Object* o){ yield(); } #End If [/CODE]
C candide Active Member Licensed User Longtime User Jul 21, 2021 #2 can we use it in a loop with "Millis" to make a no blocking Delay ?
hatzisn Expert Licensed User Longtime User Jul 22, 2021 #3 I am not sure I understood what you wrote to me... Can you provide an example? I suppose your answer is the following but I would like to understand better what you wrote: B4X: 'Either write: Delay(1) 'Or RunNative("yld", Null)
I am not sure I understood what you wrote to me... Can you provide an example? I suppose your answer is the following but I would like to understand better what you wrote: B4X: 'Either write: Delay(1) 'Or RunNative("yld", Null)
C candide Active Member Licensed User Longtime User Jul 22, 2021 #4 sorry if i am not clear i was thinking at something like that to make a not blocking Delay(xx) : Code: Sub pause(ms As UInt) 'no blocking delay Dim start As ULong = Micros Do While (start +ms > Millis) RunNative("yield",Null) Loop End Sub #if C void yield (B4R::Object* u) {yield();} #End If
sorry if i am not clear i was thinking at something like that to make a not blocking Delay(xx) : Code: Sub pause(ms As UInt) 'no blocking delay Dim start As ULong = Micros Do While (start +ms > Millis) RunNative("yield",Null) Loop End Sub #if C void yield (B4R::Object* u) {yield();} #End If
hatzisn Expert Licensed User Longtime User Jul 22, 2021 #5 It looks correct but a trial will let you know. The non blocking though is not for your code execution which keeps looping but for the ESP8266 background tasks.
It looks correct but a trial will let you know. The non blocking though is not for your code execution which keeps looping but for the ESP8266 background tasks.
C candide Active Member Licensed User Longtime User Jul 22, 2021 #6 after test, it don't help on B4R side, it is a blocking sub
hatzisn Expert Licensed User Longtime User Jul 23, 2021 #7 candide said: after test, it don't help on B4R side, it is a blocking sub Click to expand... hatzisn said: ....The non blocking though is not for your code execution which keeps looping but for the ESP8266 background tasks... Click to expand... This is the expected behavior because as far as my knowledge goes MCUs do not support multithreading directly but only though interrupts. See here: Do microcontrollers support threading? It has been a while since I took "Embedded Systems" course where we studied "Super-Loops", "RTOS", Semaphores, Multitasking (cooperative vs premptive) so sorry for this question. We have an an electronics.stackexchange.com
candide said: after test, it don't help on B4R side, it is a blocking sub Click to expand... hatzisn said: ....The non blocking though is not for your code execution which keeps looping but for the ESP8266 background tasks... Click to expand... This is the expected behavior because as far as my knowledge goes MCUs do not support multithreading directly but only though interrupts. See here: Do microcontrollers support threading? It has been a while since I took "Embedded Systems" course where we studied "Super-Loops", "RTOS", Semaphores, Multitasking (cooperative vs premptive) so sorry for this question. We have an an electronics.stackexchange.com