cancel
Showing results for 
Search instead for 
Did you mean: 

PWM pausing

developer2
Senior
Posted on August 07, 2013 at 13:52

Hi All,

i'm using on STM32F417 PWM on TIM4 CH2, i have successfully initialized PWM, i have there LED with blinking on 2Hz,

i would like to pause and i would like to return PWM to initial state with configured polarity,

is it possible with one command ?

when i use only TIM_Cmd( TIM4, DISABLE);

the LED stays in the last state, sometimes stays lighting and sometimes stays in off state,

Thank You for all replies,

Kind regards ...

#!telegraphing
8 REPLIES 8
Posted on August 07, 2013 at 14:11

TIM4->CCR2 = 0;  Would be more predictable

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
developer2
Senior
Posted on August 07, 2013 at 14:59

here is my source:

DEBUG_LED_GREEN1_TIM4CH2(x)

{

  if(x==0)

  {

   TIM_SetCompare2( TIM4, 0);

   TIM_Cmd( TIM4, DISABLE);

   TIM_CtrlPWMOutputs( TIM4, DISABLE );

  }

  else

  {

   TIM_SetAutoreload( TIM4, x);

   TIM_SetCompare2( TIM4, (x/2==0?1:(x/2)) );

   TIM_Cmd( TIM4, ENABLE);

  }

}

still no success :(

i tried:

   TIM_Cmd( TIM4, DISABLE);

   TIM_SetCompare2( TIM4, 0);

   TIM_CtrlPWMOutputs( TIM4, DISABLE );

and also:

   TIM_Cmd( TIM4, DISABLE);

   TIM_CtrlPWMOutputs( TIM4, DISABLE );

   TIM_SetCompare2( TIM4, 0);

:(

DAS.ANIL KUMAR
Associate II
Posted on June 20, 2014 at 09:22

I have same problem.... i used tim1 ch4 and ch3 i want to start channel3 after 1 us  or delay betwwen ch3 and ch4  of 1 us ....plz help me ..

thanks

Posted on June 20, 2014 at 13:51

The timers really don't work that way, there is a single counting element and the CCRx are just latches/comparators.

If you want to impart some phase shift of one channel vs the next, use toggle mode, however this will always give you 50/50 duty unless you actively reprogram the TIMx->CCRx values ahead of the counter.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DAS.ANIL KUMAR
Associate II
Posted on June 21, 2014 at 08:14

thank u for reply .............. how can i shift the phase  for 1 us delay.between these channel signal . which register value used for phase shift  ..i am using stvd and stm8s103.......thanks .

Posted on June 21, 2014 at 14:28

What's with the periods?

This is an STM32 forum, if you have an STM8 question post it to that forum.

If I had a 72 MHz system clock, with no prescaler 1us would be 72 ticks, and to get a phase shift in toggle mode you'd advance one CCRx by 72 with respect to the other.

TIM1->CCR1 = N;

TIM2->CCR2 = N + 72; // modulo period as required

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DAS.ANIL KUMAR
Associate II
Posted on June 23, 2014 at 07:19

thank u sir,   i didnot find phase shift in stm8 foroum thats why i am here.........i am using 16 Mhz internal freq.  i am generating  both signal with 10us for on and 8 us for off and continue and i want to 1 us second delay between these signal  or 2nd sinal start after 1us and continue.

plz help me   thanks

Posted on June 23, 2014 at 14:47

thank u sir,   i didnot find phase shift in stm8 foroum thats why i am here.........i am using 16 Mhz internal freq.  i am generating  both signal with 10us for on and 8 us for off and continue and i want to 1 us second delay between these signal  or 2nd sinal start after 1us and continue.

 

plz help me   thanks

Then open a new question in the STM8 forum, the two platforms are not compatible.

Failing that you'll have 2 rtfm.....

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..