Hello Everybody,
I would like to share fix for discussed issue.
There are two FreeRTOS versions (8.2.3 and 9.0.0) available in distribution system (mcuxpresso.nxp.com).
Version depends on the release in which specific board become supported.
Each version have slightly different code organization for low power tickless idle mode.
I have prepared patch with following updates:
---- v. 8.2.3. ----
boards\<board>\rtos_examples\freertos_tickless\FreeRTOSConfig.h
original: #define configLPTMR_RATE_HZ (configCPU_CLOCK_HZ)
fixed: #define configLPTMR_CLOCK_HZ (1000)
freertos_8.2.3\Source\portable\<tool>\<architecture>\port.c:
vPortSuppressTicksAndSleep()
original: ulCompleteTickPeriods = LPTMR_GetCurrentTimerCount(TICKLESS_LPTMR_BASE_PTR);
fixed: ulCompleteTickPeriods = LPTMR_GetCurrentTimerCount(TICKLESS_LPTMR_BASE_PTR)/ulLPTimerCountsForOneTick;
prvSetupTimerInterrupt()
original: ulLPTimerCountsForOneTick = configSYSTICK_CLOCK_HZ / configLPTMR_RATE_HZ;
fixed: ulLPTimerCountsForOneTick = ( configLPTMR_CLOCK_HZ / configTICK_RATE_HZ );
---- v. 9.0.0. ----
boards\<board>\rtos_examples\freertos_tickless\FreeRTOSConfig.h
original: #define configLPTMR_RATE_HZ (configCPU_CLOCK_HZ)
fixed: #define configLPTMR_CLOCK_HZ (1000)
freertos_9.0.0\Source\portable\<tool>\<architecture>\fsl_tickless_lptmr.c
vPortSuppressTicksAndSleep()
original: ulCompleteTickPeriods = LPTMR_GetCurrentTimerCount(pxLptmrBase);
fixed: ulCompleteTickPeriods = LPTMR_GetCurrentTimerCount(pxLptmrBase)/ulLPTimerCountsForOneTick;
prvSetupTimerInterrupt(
original: ulLPTimerCountsForOneTick = configSYSTICK_CLOCK_HZ / configLPTMR_RATE_HZ;
fixed: ulLPTimerCountsForOneTick = ( configLPTMR_CLOCK_HZ / configTICK_RATE_HZ );
I would like to explain configLPTMR_CLOCK_HZ macro, because it is confusing. Its purpose is to pass low power timer clock frequency to tick functions in FreeRTOS core files.
There is difference in comparison with systick timer (common across different architectures), because systick timer is initialized directly in official port.c (in v 8.2.3 or in fsl_tickless_lptmr.c in 9.0.0) file (prvSetupTimerInterrupt function). The low power timers are different between families (kinetis, lpc) and hence it need to be initialized in application (LPTMR_Init in main). Macro configLPTMR_CLOCK_HZ cannot be changed without update of low power timer initialization in main function (LPTMR_Init). It is not perfect, but it is the reason for existence of configLPTMR_CLOCK_HZ. Current implementation have this inconsistency, and we are going to rework it.
Another topic to explain is split of port.c into several files in v 9.0.0. It is because we are supporting several different low power timers across one architecture (e.g. ARM_CM4F). LPTMR is used in kinetis line, and RTC in LPC line.
I would like to thanks Martis and other people in discussion for reporting the issue. I am sorry for delay in my reaction.
Regards,
David (FreeRTOS integrator)