The os_tick_init function initializes the hardware timer as
a system tick timer and starts it. It is used in Cortex™-M
library, if you want to use alternate peripheral timer as RTX tick
timer. If this function does not exist in a project, the default
SysTick timer is used as RTX tick timer.
The os_tick_init function is part of RL-RTX. The prototype
is defined in rtl.h. You can customize the function in
rtx_config.c.
Note
The os_tick_init function is used in Alternate Tick Timer
configuration. It is not supported in ARM7™/ARM9™ library
version.
Return Value
The os_tick_init function returns the Cortex-M interrupt
number of alternate peripheral timer.
#include <rtl.h>
int os_tick_init (void) {
/* Initialize hardware timer as system tick timer. */
LPC_SC->PCONP |= (1<<16); // Enable power for RIT
LPC_SC->PCLKSEL1 &= ~(3<<26);
LPC_SC->PCLKSEL1 |= (1<<26); // RIT Clock = CCLK
LPC_RIT->RICOMPVAL = OS_TRV; // Set match value
LPC_RIT->RICOUNTER = 0; // Set count value to 0
LPC_RIT->RICTRL = (1<<3) | // Timer enable
(1<<1) | // Enable clear on match
(1<<0); // Clear interrupt flag
return (RIT_IRQn); /* Return IRQ number of timer (0..239) */
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.