You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was developing a home project, and need to make a 5 minutes delay. Of course, I use delay(300000);, but when I compile and upload the code, the delay was approximately of 1 minute.
Since I have experience with c++ and arduino, I dig in the repository code and found that the delay() function was defined as vPortDelay(), so i search it's definition.
When I found it, discover that in line 651 "vTaskDelay( (TickType_t) (ms) / portTICK_PERIOD_MS );" is casting an unsigned long to a TickType_t (which is defined as uint16_t) before doing the operation. That results in an overflow of the TickType_t, which lost all the unsigned long data (almost all data, until 65535 is all ok) before operating it to convert it to TickType_t and use it on vTaskDelay() function.
My thoughs was the brackets of (ms) should be over the entire operation, like this (TickType_t) (ms / portTICK_PERIOD_MS) for it to work properly. I do the operation on my code, and use vTaskDelay() instead of delay(), and it worked as expected, for 300000 ms I had a 5 minutes delay.
So I raise this issue to inform, what I supose is a typo error, this library error.
I don't belive that someone else are going to use a 5 minutes delay, but I used and found this error.
I don't speak English natively, so I used Google Translate to help me write.
The text was updated successfully, but these errors were encountered:
I was developing a home project, and need to make a 5 minutes delay. Of course, I use
delay(300000);
, but when I compile and upload the code, the delay was approximately of 1 minute.Since I have experience with c++ and arduino, I dig in the repository code and found that the
delay()
function was defined asvPortDelay()
, so i search it's definition.When I found it, discover that in line 651 "
vTaskDelay( (TickType_t) (ms) / portTICK_PERIOD_MS );
" is casting anunsigned long
to aTickType_t
(which is defined asuint16_t
) before doing the operation. That results in an overflow of theTickType_t
, which lost all theunsigned long
data (almost all data, until 65535 is all ok) before operating it to convert it toTickType_t
and use it onvTaskDelay()
function.My thoughs was the brackets of
(ms)
should be over the entire operation, like this(TickType_t) (ms / portTICK_PERIOD_MS)
for it to work properly. I do the operation on my code, and usevTaskDelay()
instead ofdelay()
, and it worked as expected, for300000 ms
I had a 5 minutes delay.So I raise this issue to inform, what I supose is a typo error, this library error.
I don't belive that someone else are going to use a 5 minutes delay, but I used and found this error.
I don't speak English natively, so I used Google Translate to help me write.
The text was updated successfully, but these errors were encountered: