system timer, system tick

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

system timer, system tick

707件の閲覧回数
karmegancjk
Contributor III

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.

タグ(2)
0 件の賞賛
返信
1 返信

676件の閲覧回数
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @karmegancjk

2. This depends on your application. PIT module is separate from the MCU, does not affect core performance, since it is its own module. If your application does not need to optimize performance, you can use SysTick, which is easier to configure.

3. I explain how to configure OsIf and use SysTick in this thread: Solved: Delay function using OSIF - NXP Community.

4. This thread talks about SysTick priority and IRQ handling: Solved: How can I configure SysTick timer interrupt priority ? - NXP Community.

5. OsIf_Timer_System_Init(void) function initializes SysTick if system timer is selected in the BaseNXP component.

Best regards,
Julián

0 件の賞賛
返信