Timer Interrupts

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
2,807件の閲覧回数
Awera
Contributor III

Hi

 

How can I use a DTIM interrupt?

 

I want to create a periodic interrupt but I don't know how. I have used the ISR example of MQX's folder but I don't want to use PIT for my service.

 

Has anyone an example?

 

Thank you

0 件の賞賛
返信
1 解決策
1,669件の閲覧回数
LordMark
Contributor IV

I'm using M52259DEMOKIT.

 

I'm using GPT for output compare match with the following code:

 

 

VMCF5225_STRUCT_PTR  reg_ptr = (VMCF5225_STRUCT_PTR)BSP_IPSBAR;[...]void gpt_init (){ reg_ptr -> GPT.GPTIOS |= GPT_GPTIOS_IOS0;     //Attivazione Output Compare 0   reg_ptr -> GPT.GPTC0 = 0x00;        //GPTC0 resettato a 0   reg_ptr -> GPT.GPTDDR |= GPT_GPTDDR_DDRT0;     //Pin OC0 come uscita    reg_ptr -> GPT.GPTCTL1 |= GPT_GPTCTL1_OUTPUT0_NOTHING;  //Nessun effetto sul piedino OC0    reg_ptr -> GPT.GPTSCR2 |= GPT_GPTSCR2_PR_16;    //Prescaler 1/16      _int_install_kernel_isr (MCF5225_INT_TIMA_C0F, OC0_service);        reg_ptr -> GPT.GPTFLG1 |= GPT_GPTFLG1_CF0;     //clear flag   reg_ptr -> GPT.GPTIE |= GPT_GPTIE_CI0;      //Interrupt su OC0       _mcf5225_int_init (MCF5225_INT_TIMA_C0F, gpt_level, gpt_priority, 1);}[...]__declspec(interrupt:0) void OC0_service (){    count++;    reg_ptr -> GPT.GPTFLG1 |= GPT_GPTFLG1_CF0;     //clear flag}

 

I set MQX_ROM_VECTORS to 0 in the user_config.h and rebuilt bsp and psp. In the code I'm using the function _int_install_kernel_isr so that my interrupt routine is direct without MQX intervention. (It should allow faster interrupts)

 

You may try to modify the code to your purposes. Hope it helps.

 

Moreover, something about the DTIM is here https://community.freescale.com/message/60070#60070

 

Regards,

Marco

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,670件の閲覧回数
LordMark
Contributor IV

I'm using M52259DEMOKIT.

 

I'm using GPT for output compare match with the following code:

 

 

VMCF5225_STRUCT_PTR  reg_ptr = (VMCF5225_STRUCT_PTR)BSP_IPSBAR;[...]void gpt_init (){ reg_ptr -> GPT.GPTIOS |= GPT_GPTIOS_IOS0;     //Attivazione Output Compare 0   reg_ptr -> GPT.GPTC0 = 0x00;        //GPTC0 resettato a 0   reg_ptr -> GPT.GPTDDR |= GPT_GPTDDR_DDRT0;     //Pin OC0 come uscita    reg_ptr -> GPT.GPTCTL1 |= GPT_GPTCTL1_OUTPUT0_NOTHING;  //Nessun effetto sul piedino OC0    reg_ptr -> GPT.GPTSCR2 |= GPT_GPTSCR2_PR_16;    //Prescaler 1/16      _int_install_kernel_isr (MCF5225_INT_TIMA_C0F, OC0_service);        reg_ptr -> GPT.GPTFLG1 |= GPT_GPTFLG1_CF0;     //clear flag   reg_ptr -> GPT.GPTIE |= GPT_GPTIE_CI0;      //Interrupt su OC0       _mcf5225_int_init (MCF5225_INT_TIMA_C0F, gpt_level, gpt_priority, 1);}[...]__declspec(interrupt:0) void OC0_service (){    count++;    reg_ptr -> GPT.GPTFLG1 |= GPT_GPTFLG1_CF0;     //clear flag}

 

I set MQX_ROM_VECTORS to 0 in the user_config.h and rebuilt bsp and psp. In the code I'm using the function _int_install_kernel_isr so that my interrupt routine is direct without MQX intervention. (It should allow faster interrupts)

 

You may try to modify the code to your purposes. Hope it helps.

 

Moreover, something about the DTIM is here https://community.freescale.com/message/60070#60070

 

Regards,

Marco

 

 

0 件の賞賛
返信
1,669件の閲覧回数
Awera
Contributor III

Thank you very mauch Marco

 

I have a question about timer PIT0: if I change the PIT0's registers in my main task, the functions like _time_add or _time_get and others, will be change? I mean if I can use this functions in the same way than before changing this registers.

 

Thanks

0 件の賞賛
返信
1,669件の閲覧回数
LordMark
Contributor IV

Well, I never used PIT timer so I cannot answe you precisely. But I think that you can use those function anyway. They only involve ticks and no other settings.

1,669件の閲覧回数
Awera
Contributor III

Thank you Mark.

 

Your posts has been really useful for me

0 件の賞賛
返信