OpenSourceEBike / TSDZ2_wireless

TSDZ2_wireless
35 stars 11 forks source link

timing loop that fires too often? #116

Open 4var1 opened 3 years ago

4var1 commented 3 years ago

I was browsing the code - and spotted what I think is another buggy loop timer - is the same construct as was being used in the main loop that caused it to run a lot faster than expected as if the timer resolution is high enough - the mod test will be true for many cycles rather than just one. I'll take a closer look when I have more time...

static void main_timer_timeout(void *p_context) { UNUSED_PARAMETER(p_context);

main_ticks++;

if (main_ticks % (1000 / MSEC_PER_TICK) == 0) ui32_seconds_since_startup++;

if ((main_ticks % (50 / MSEC_PER_TICK) == 0) && // every 50ms m_rt_processing_stop == false) rt_processing(); }

casainho commented 3 years ago

We need to use APP_TIMERS as is being done on the wireless remote and we would use an APP_TIMER to fire up every 50ms.