How to get a timer component to timeout in us?

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

How to get a timer component to timeout in us?

跳至解决方案
1,056 次查看
danielchai
Senior Contributor I

Hi All,

Now I am trying to use the timer component in MQX4.0.1.

Is it possible to make the timer timeout in us? Or what's the resolution for the timer component?\

Thank you.

-Daniel

0 项奖励
1 解答
646 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Daniel,

I have not used hwtimer but if you can reach the period you need for your interrupt there is no porblem.

In case you cannot reach the desired period with hwtimer you may try with the PIT. The difference is that hwtimer is an MQX driver and the interrupts is handled by the RTOS while the example I provided can bypass MQX, the interrupts are handled directly by the core andd you can get a smaller period.

BR,

Carlos

在原帖中查看解决方案

0 项奖励
5 回复数
646 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Daniel,

Please take a look to the thread below, here I configured PIT and reached 1uS interrupt. Please note that you can let MQX handle the interrupts or bypass MQX, to reach 1uS I had to bypass MQX. In the project there is a macro to set if you want MQX to handle interrupts or bypass MQX.

https://community.freescale.com/thread/324484

Hope this helps.

Regards,

Carlos

0 项奖励
646 次查看
danielchai
Senior Contributor I

Hi Carlos,

Thank you.

Now I am using the hwtimer in MQX to generate the interrupt in micro-second and it seems working.

Is there any disadvantage of using hwtimer?

-Daniel

0 项奖励
647 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Daniel,

I have not used hwtimer but if you can reach the period you need for your interrupt there is no porblem.

In case you cannot reach the desired period with hwtimer you may try with the PIT. The difference is that hwtimer is an MQX driver and the interrupts is handled by the RTOS while the example I provided can bypass MQX, the interrupts are handled directly by the core andd you can get a smaller period.

BR,

Carlos

0 项奖励
646 次查看
danielchai
Senior Contributor I

Hi Carlos,

Thank you. For the hwtimer, I can get a 3us accurate period, and it works for me.

-Daniel

0 项奖励
646 次查看
troide
Contributor II

Hello Daniel,

Would you please give me more details on how you got us resolution in hwtimer? The smallest resolution I could get is 1ms by using  hwtimer_set_period().

I could use PIT approach as Carlos mentioned in the last post but I would prefer to stick with MQX handler.

Cheers!

0 项奖励