MicroOcpp icon indicating copy to clipboard operation
MicroOcpp copied to clipboard

Port - NXP iMX RT1064 - CUSTOM_TIMER

Open GanesanGuru opened this issue 2 years ago • 1 comments

Hi @matth-x , I've follow the steps and when I tried to connect the MO_CUSTOM_TIMER to iMX RT1064 EVK, the mongoose connection/MO_CUSTOM_WS is being resetting continuously.

LWIP Network stack that is running in iMX RT1064. Hence, I've passed the sys_now to mocpp_set_timer - callback function as mocpp_set_timer(sys_now);

If I'm not passing that parameter, the code executes - but for later stages of developemnt - as timer configuration is mandatory, aid me to fix this

GanesanGuru avatar Jan 29 '24 07:01 GanesanGuru

Hi @GanesanGuru,

The timer should return the milliseconds. Sometimes the host system timers have a different resolution, for example 10ms, or even 1µs. A conversion to milliseconds is necessary then.

Here's an example for the ESP-IDF which configures the default tick rate of FreeRTOS to be 100 ticks per second:

https://github.com/matth-x/MicroOcpp/blob/12d4868200d9675d98ff81b9c226e5deace64c12/src/MicroOcpp/Platform.cpp#L45-L60

To make something similar, pass your own mocpp_tick_ms_espidf conversion function to mocpp_set_timer.

Note that MO expects that the timer uses the full 2^32 bit value range of unsigned long. It should take the timer ~49.7 days to reach the maximum value and afterwards it should roll over to 0. The ESP-IDF platform integration achieves that by using a separate counter for example.

matth-x avatar Feb 04 '24 20:02 matth-x