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) */
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.