B4R Question Timer misbehaves

hatzisn

Expert
Licensed User
Longtime User
Good evening everyone,

I am creating an ESP8266 project that uses an LCD 1602 screen. The 1602 LCD is powered with 5 volts with external power where it is needed and I only control what needs to be controlled with the 3,3 V of the ESP8266 pins.

I am writting all this if it is related in any way with what is happening. When I start the project it downloads some data from a server and then executes a code in a timer1_Tick event. The timer is initialized with an interval of 1000 milliseconds. When all the data has been downloaded I set the timer1.Enabled = True and naturally I expect the code to execute every 1 sec (1000 ms). My ESP8266 does not share this wish with me and instead it does its own thing. In the beggining I though that the timer did not work but then I discovered (accidentally when switched to another window to send an e-mail and then returned to it) that it fires every 197120 almost milliseconds. Here is the interval calculated with the millis I log in every Tick.



Any ideas for this misbehavior?
 
Last edited:

hatzisn

Expert
Licensed User
Longtime User
I just had an epiphany that was proved correct. Instead of initializing the timer in AppStart I tried to initialize it in the end of all the procedures just before it is set to true. This was proved correct. It seems that when dealing with a project that requires a fair amount of memory the Scheduler of the timer loses the ball. I suppose it changes its memory and executes the Tick when ever this memory "says" so.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…