IMXRT1024 GPT Timer Usage Delay

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

IMXRT1024 GPT Timer Usage Delay

跳至解决方案
2,392 次查看
Lukas_Frank
Senior Contributor I

Hi All,

Has anybody a example for a simple delay,sleep function in milliseconds

microsecond by using GPT Timer?

I dont know how can calculate the time by using Timer. Could you help me please?

Just like below :
Delay(1000); //1sec delay

Sleep(1000);//1sec sleep 


Thanks and Regards.

0 项奖励
回复
1 解答
2,320 次查看
Omar_Anguiano
NXP TechSupport
NXP TechSupport

I apologize for my delayed reply.
1. No, the delay time is based on the period of the  GPT timer. If the GPT clock is 1Mz then each tick equals 1us.

2. CNT register contains the current value of the main counter and the output compare value holds the value that determines when a compare event is generated on the corresponding Output Compare Channel. When the CNT value equals the Compare value a compare event is generated. The timer counts based on the clock source of the module.

Omar_Anguiano_1-1630695422587.png

3. You should use the clock source frequency of the module.

If you have more questions do not hesitate to ask me.
Best regards,
Omar

在原帖中查看解决方案

0 项奖励
回复
5 回复数
2,357 次查看
Lukas_Frank
Senior Contributor I

EDIT:

Dear @Omar_Anguiano Hi again,

I have three more question.

Q1:Is the unit of delay_time second in the equation that you attach your answer?

Q2: What is the relationship between base->CNT increasion and output compare value? So What is the time between the value of base->CNT when it pass form n to n+1 for example 0 to 1.

Q3:When should I use base->CNT value if I can obtain delay with your equation?

Thanks and Regards.

0 项奖励
回复
2,321 次查看
Omar_Anguiano
NXP TechSupport
NXP TechSupport

I apologize for my delayed reply.
1. No, the delay time is based on the period of the  GPT timer. If the GPT clock is 1Mz then each tick equals 1us.

2. CNT register contains the current value of the main counter and the output compare value holds the value that determines when a compare event is generated on the corresponding Output Compare Channel. When the CNT value equals the Compare value a compare event is generated. The timer counts based on the clock source of the module.

Omar_Anguiano_1-1630695422587.png

3. You should use the clock source frequency of the module.

If you have more questions do not hesitate to ask me.
Best regards,
Omar

0 项奖励
回复
2,370 次查看
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

Hope you are well.
We don´t have a specific example but I have some suggestions to achieve this. Based on the frequency of the timer you can calculate when the interruption should occur.
If you want a 1-second delay and the GPT frequency is 10Mhz you should set the output compare value to 10,000,000 ticks.
This equation might help:

Omar_Anguiano_1-1629819742356.png
You can use a loop cycle that exits when the interruption of the GPT occurs. The SDK has an example that can be used as a starting point for this.

Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar

0 项奖励
回复
2,363 次查看
Lukas_Frank
Senior Contributor I

Hi Dear @Omar_Anguiano ,

 

That is exactly what I am trying to do. I watch some of the tutorials on STM but I did not know the unit of output compare value is Tick. I just looked for the interrupt method that system calls when every tick is occured. I will try your suggestions. 

EDIT:

Dear @Omar_Anguiano Hi again,

I have three more question.

Q1:Is the unit of delay_time second in the equation that you attach your answer?

Q2: What is the relationship between base->CNT increasion and output compare value? So What is the time between the value of base->CNT when it pass form n to n+1 for example 0 to 1.

Q3:When should I use base->CNT value if I can obtain delay with your equation?

Thanks and Regards.

 

0 项奖励
回复
2,329 次查看
Lukas_Frank
Senior Contributor I

Hi Dear @Omar_Anguiano 

 

Could you reply me please???

0 项奖励
回复