RT1051: QTIMER configured as PWM

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

RT1051: QTIMER configured as PWM

Jump to solution
1,554 Views
mastupristi
Senior Contributor I

On an RT1051 I use QTIMERS to make PWM signals.

I need that when I set 0 to duty the output stays low, while if I set 100 it stays high.

I have tried by modifying the SDK example by imposing

 

QTMR_SetupPwm(BOARD_QTMR_BASEADDR, BOARD_QTMR_PWM_CHANNEL, QTMR_PWM_OUTPUT_FREQUENCY, 0, false, QTMR_SOURCE_CLOCK);

 

or

 

QTMR_SetupPwm(BOARD_QTMR_BASEADDR, BOARD_QTMR_PWM_CHANNEL, QTMR_PWM_OUTPUT_FREQUENCY, 100, false, QTMR_SOURCE_CLOCK);

 

but I cannot get the desired result

 

how can i get what i want?

 

best regards

Max

 

Labels (1)
0 Kudos
Reply
1 Solution
1,527 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

if I understand correctly there is no way to avoid glitches when I set duty 0% or 100%, right?

>>>>Yes, no way to avoid the glitch for the 0% or 100% percent. As a workaround, if you do not want any glitch, in the application code, when  the duty cycle is 0% or 100%, you can set the pad as GPIO output mode and output low or high.

BR

XiangJun Rong

 

View solution in original post

0 Kudos
Reply
3 Replies
1,537 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The 100% percent and 0% percent are extreme examples, if you use the other percent for example from 1% to 99%, is the PWM duty cycle okay?

The  QTMR_SetupPwm()  uses the variable-Frequency  PWM mode, the TMR_COMP1 represents the PWM LOW logic time, the TMR_COMP2 represents the PWM high logic time(dependent on plarity of PWM signal).

The PWM period value is QTMR_SOURCE_CLOCK/QTMR_PWM_OUTPUT_FREQUENCY, the TMR_COMP2 represents the high time, it is (duty cycle percent)*QTMR_SOURCE_CLOCK/QTMR_PWM_OUTPUT_FREQUENCY.

The TMR_COMP1 represents the LOW time, it is (1-duty cycle percent)*QTMR_SOURCE_CLOCK/QTMR_PWM_OUTPUT_FREQUENCY.

For the extreme duty cycle 0% and 100%, one of the TMR_COMP1 or TMR_COMP2 is zero, do you see glitch or whatever?

For detailed information, pls refer to section 46.6.5.14 Variable-Frequency PWM Mode in IMXRT1050RM.pdf

 

BR

XiangJun Rong

 

 

0 Kudos
Reply
1,530 Views
mastupristi
Senior Contributor I

if you use the other percent for example from 1% to 99%, is the PWM duty cycle okay?

Yes

 

For the extreme duty cycle 0% and 100%, one of the TMR_COMP1 or TMR_COMP2 is zero, do you see glitch or whatever?

Yes

 

so if I understand correctly there is no way to avoid glitches when I set duty 0% or 100%, right?

 

best regards

Max

0 Kudos
Reply
1,528 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

if I understand correctly there is no way to avoid glitches when I set duty 0% or 100%, right?

>>>>Yes, no way to avoid the glitch for the 0% or 100% percent. As a workaround, if you do not want any glitch, in the application code, when  the duty cycle is 0% or 100%, you can set the pad as GPIO output mode and output low or high.

BR

XiangJun Rong

 

0 Kudos
Reply