QTMR_SetTimerPeriod() to set the new period, how to reset timer to use the new period immediately?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

QTMR_SetTimerPeriod() to set the new period, how to reset timer to use the new period immediately?

Jump to solution
640 Views
felix1
Contributor IV

The SDK example evkbimxrt1050_qtmr_timer, it change timer period using

/* Set the second channel count which increases every millisecond, set compare event for 10 second */
QTMR_SetTimerPeriod(BOARD_QTMR_BASEADDR, BOARD_SECOND_QTMR_CHANNEL, 10000);

and

/* Set the second channel count which increases every millisecond, set compare event for 65.5 second */
QTMR_SetTimerPeriod(BOARD_QTMR_BASEADDR, BOARD_SECOND_QTMR_CHANNEL, 0xFFFF);

I want to change the quad timer period dynamically like example, but if I just use QTMR_SetTimerPeriod() to change the period, the timer will trigger until it meet the new  period tick value, it is longer than the new period. 

IMXRT1050RM, 53.6.2 Usage of Compare Registers also mention this:

"Use caution when changing COMP1 and COMP2 while the counter is active. If the
counter has already passed the new value, it will count to FFFFh or 0000h, roll over, then
begin counting toward the new value. The check is: Count=CMPx, not Count > COMP1
or Count < COMP2."

Can you show me how to reset the timer to use the new period immediately?

Labels (1)
Tags (1)
0 Kudos
1 Solution
633 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi felix1,

   When you read the reference manual, the caution part, do you also read the following content?

The use of the CMPLD1 and CMPLD2 registers to compare values will help to minimize
this problem.

  Please read chapter 53.6.3 Usage of Compare Load Registers.

  When you use the CMPLD1 and CMPLD2, it will minimize that mentioned issues. You can change the CMPLD register, and update the COMP register.

  You also can refer to this post:

https://community.nxp.com/t5/i-MX-RT/PWM-VARIABLE-DUTY-CYCLE/m-p/958047

 

Wish it helps you!

Best Regards,

Kerry

View solution in original post

0 Kudos
1 Reply
634 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi felix1,

   When you read the reference manual, the caution part, do you also read the following content?

The use of the CMPLD1 and CMPLD2 registers to compare values will help to minimize
this problem.

  Please read chapter 53.6.3 Usage of Compare Load Registers.

  When you use the CMPLD1 and CMPLD2, it will minimize that mentioned issues. You can change the CMPLD register, and update the COMP register.

  You also can refer to this post:

https://community.nxp.com/t5/i-MX-RT/PWM-VARIABLE-DUTY-CYCLE/m-p/958047

 

Wish it helps you!

Best Regards,

Kerry

0 Kudos