Hi,
I am trying to migrate my application from RTOS to RTOS2 on a LPC4337. I did not have any issue yet to migrate M4 application which uses the SysTick timer for the kernel tick.
But I am not able to configure the M0 OS tick using an alternate timer (M0 do not have acces to the SysTick Timer).
With the RTOS I use the RITIMER (freq. = 1000Hz) as an alternate timer In the file "RTX_Conf_CM.c" my functions are :
int os_tick_init (void) { (...) //RITIMER configuration return(M0_RITIMER_OR_WWDT_IRQn); } uint32_t os_tick_val (void) { return (0); } uint32_t os_tick_ovf (void) { return (0); } void os_tick_irqack (void) { RIT_GetIntStatus(LPC_RITIMER); }
And I call the "OS_Tick_Handler" function in the assembly file instead of the RIT handler (I have no issue with RTOS, everything works fine).
With the RTOS2 I was stuck using the RITIMER (the interrupt and acknowledge did not work correctly) so I switched with the TIMER3 (freq. = 1MHz) Here are my functions :
int32_t osRtxSysTimerSetup (void){ (...) //TIMER3 Init code NVIC_SetPriority(M0_TIMER3_IRQn,(1UL << __NVIC_PRIO_BITS) - 1UL); //? NVIC_EnableIRQ(M0_TIMER3_IRQn); return(M0_TIMER3_IRQn); } /// Enable System Timer. void osRtxSysTimerEnable (void){ TIM_Cmd(LPC_TIMER3,ENABLE); } void osRtxSysTimerDisable (void){ TIM_Cmd(LPC_TIMER3,DISABLE); } void osRtxSysTimerAckIRQ (void){ TIM_ClearIntPending(LPC_TIMER3,TIM_MR0_INT); NVIC_ClearPendingIRQ(M0_TIMER3_IRQn); } uint32_t osRtxSysTimerGetCount (void){ return (_tick); //? } uint32_t osRtxSysTimerGetFreq (void){ return 1000000; } void M0_TIMER3_IRQHandler (void){ _tick++; //? osRtxTick_Handler(); }
I have no idea of what I need to implement in these functions for an alternate timer (Keil doc. and examples are very light on this topic). My TIMER3 interrupt works and is called at the desired frequency (1MHz), all other functions are called by the system but I am not sure about the return values. I tried a lot of differents frequencies, differents return values, etc.
I have only one thread running at the moment with a simple loop that sends a message after a short delay (I tried with "osDelayUntil" and "osDelay"). Depending on the delay, the loop can work twice or three times then the system "gets stuck" and loops forever in the "osRtxIdleThread" function.
int32_t main(void) { SystemInit(); //init system osKernelInitialize(); osThreadNew(Init_Thread, NULL, NULL); // start init task osKernelStart(); for (;;); } void Init_Thread(void *argument){ while(1){ (...)//send message through UART //osDelay(10); osDelayUntil(osKernelGetTickCount() + 10); } }
Could someone help me implementing an alternate timer or would have more documentations on this topic to guide me ?
Thank you.
I re-open this topic because I encounter a new issue. Everything worked fine for the last weeks using the solution described above and using CMSIS 5.01.
Last week I updated the CMSIS Package from 5.01 to 5.20 available in keil (I have the same issue using CMSIS 5.10).
With this new CMSIS version the code does not compile anymore. The variable "osRtxInfo.kernel.sys_freq" does not exist in these versions (I assume that I simply need to replace it by SystemCoreClock variable).
With this modification my project compiles but as soon as I call "osDelay" or "osDelayUntil" functions, my code gets stuck. I am not able to use Delay functions anymore (nothing else was changed in my code and if I re-use CMSIS 5.01 everything works fine).
What should I add/modify to be able to update the CMSIS software pack from 5.01 to 5.2 and keep using the RIT Timer as alternate systick timer for my LPC4337 M0 core (I have no issue with the LPC4337 M4 core, which uses the systick timer) when updating the CMSIS software pack)?
I tried to contact Keil Support but they assumed that it should be caused by internal API changes so maybe someone here could help me !
Regards.