LPC5506 100Hz PWM with dutycycle change glitching

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC5506 100Hz PWM with dutycycle change glitching

Jump to solution
851 Views
francoisB
Contributor III

   

Hello,

Following this suject: https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-100Hz-PWM-with-dutycycle-change/m-p/13548...

I noticed that, even with the driver modification provided in the above subject, when using a frequency of 100Hz, the pwm is glitching (pwm stays high for too long). I use this pwm with an LED so, sometimes, it flashes. And I don't want it to sparkle like that. The issue does not occure for high frequency (or I can't see it appear).

I have this problem with my project but I can reproduce it with the example provided by NXP (sctimer pwm with dutycycle change). The glitch appears more when using debug in the while(1) of the project (in order to take some time of the µC).

 

Edit1 : I can see the glitch with the oscilloscope for a PWM at 10kHz.

Edit2 : The glitch appears on the 4 channels I am using. I can provide pictures of the glitch on channels output 2 and 4. Channel 4 has a dutycycle of 0 and the output goes to 1 for 6.6µs (so there's a short blink). At the same time, the output 2 stays high for an extra 6.6µs.

 

pwm_glitch (1).PNG

 

pwm_glitch (2).PNG

 

pwm_glitch (3).PNG

 

Thanks for helping me.

 

François

0 Kudos
1 Solution
815 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The SCTimer output pin glitch means that the event happens which set/clear the output pin, so if you want to get always LOW logic, you have to implement a workaround.

1)check if the duty cycle is 0, if it is 0,  set the pulse match register to another value which is out of range of the counter.

2)check if the duty cycle is 0, if it is 0, then configure the pin as GPIO output mode, and output low logic.

Hope it can help you

BR

XiangJun Rong

 

View solution in original post

0 Kudos
8 Replies
830 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Francois,

Pls refer to the description of the api function void SCTIMER_UpdatePwmDutycycle() in fsl_sctimer.c, the duty cycle range is from 1 to 100, it can NOT be 0.

Hope it can help you

BR

XiangJun Rong

 

xiangjun_rong_0-1637205693596.png

 

 

Tags (1)
0 Kudos
822 Views
francoisB
Contributor III

Hi,

I knew it but I forgot to initialize the dutycycle of the 4 channels to 1 (instead of 0).

I replaced every "dutycycle = 0" by "dutycycle = 1".

In fact, there's no glitch anymore because it is replaced by the dutycycle at 1. This is not really a solution because my LEDs stay slightly illuminated.

0 Kudos
816 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The SCTimer output pin glitch means that the event happens which set/clear the output pin, so if you want to get always LOW logic, you have to implement a workaround.

1)check if the duty cycle is 0, if it is 0,  set the pulse match register to another value which is out of range of the counter.

2)check if the duty cycle is 0, if it is 0, then configure the pin as GPIO output mode, and output low logic.

Hope it can help you

BR

XiangJun Rong

 

0 Kudos
800 Views
francoisB
Contributor III

Hi,

 

I succeeded to switch from PWM to GPIO but I can't find a way to switch from GPIO to PWM (the program is stucked in SCTIMER_SetupPwm).

Could give me an example or idea of how to achieve it, please ?

 

Thanks in advance.

 

François

0 Kudos
786 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think you can following up the code.

bool PinStategpioOrPWM=false; //if ture, GPIO control the pin, otherwise PWM controls the pin

if(dutyCyle==0)

{

             if(!PinStategpioOrPWM)

                {

                  configurePINGPIO();

                  PinStategpioOrPWM=true;

                  }

}

else //duty cycle is not equal to 0

{

              if(PinStategpioOrPWM)

                {

                  configurePINPWM();

                  PinStategpioOrPWM=false;

                  }

}

void configurePINPWM()

{

}

configurePINGPIO()

{

}

Hope it can help you

BR

XiangJun Rong

 

0 Kudos
773 Views
francoisB
Contributor III

Hello,

I noticed that when I go from PWM to GPIO and back to PWM, the PWM output does not go to full dutycycle.

1- PWM outputs normally (with dutycycle change)

2- I press a button to switch to GPIO because I want the LED to turn OFF.

3- I press a button to switch to PWM to have my LED turned ON (with dutycycle change). But then in this case, the max dutycycle reached seems to be the one that was in memory the time I pressed the button.

 

I don't know if it's clear. When I set back to PWM it seems that a register is not well set and thus the PWM does not go to full span.

 

Thanks in advance.

 

François

0 Kudos
766 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Regarding your question that the PWM duty cycle can not go to the full duty cycle, from knowledge, configuring the Pin as GPIO or PWM does not take effect on the PWM module, pls check your PWM code.

BR

XiangJun Rong

0 Kudos
780 Views
francoisB
Contributor III

I did something like that and succeeded on Friday, but thanks anyway (sorry for wasting your time)

0 Kudos