Hi,
I need some clarification on implementing a system tick counter.
1. I am creating 1 ms, 10 ms, and 100 ms task containers in my main loop so that I need a system tick counter periodic interrupt for every 100 us or 500 us once to increment the background run time counter. However, I can't able to enable the system tick interrupt.
2. For creating 1 ms, 10 ms, and 100 ms task containers, which one is better: a system tick counter or PIT?
3. Is there any example code available? system tick counter periodic interrupt?
4. In my project, startup_code exception.c already defined system tick ISR, and also in the vector table, IRQ number -1 system tick handler is defined. How to use the system tick ISR from main.c and how to enable IRQ number -1 interrupt ?
5. System tick counter initialization
void OsIf_System_tick_init(uint32 usec_u32) //user-defined function
{
float uSEC_value = 0;
uint32 SytemTick_Reload_Value_u32 = 0;
uSEC_value = usec_u32 * 0.000001;
SytemTick_Reload_Value_u32 = ((OsIf_apxPredefinedConfig[0]->counterFrequency) * uSEC_value) - 1 ;
/* Systick counter initialization */
S32_SysTick->CSRr = S32_SysTick_CSR_ENABLE(0u);
S32_SysTick->RVR = (SytemTick_Reload_Value_u32 & 0xFFFFFF);//24 bit only allowable
S32_SysTick->CVR = S32_SysTick_CVR_CURRENT(0U); //clear current value
S32_SysTick->CSRr = S32_SysTick_CSR_ENABLE(1u) | S32_SysTick_CSR_TICKINT(1u) | S32_SysTick_CSR_CLKSOURCE(1u); //enable system tick, choose core clock for cpu clock and enable exception
// systick priority
// systick interrupt handler
//systick interrupt enable
}
Is it the correct way or not?
Ide : S32DS V3.5.14
RTD : v4.0.0
Hardware : S32K344, S32K358.