Timer Interrupts

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Timer Interrupts

跳至解决方案
2,804 次查看
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,666 次查看
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,667 次查看
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,666 次查看
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,666 次查看
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,666 次查看
Awera
Contributor III

Thank you Mark.

 

Your posts has been really useful for me

0 项奖励
回复