2013-08-07 04:52 AM
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 ... #!telegraphing2013-08-07 05:11 AM
TIM4->CCR2 = 0; Would be more predictable
2013-08-07 05:59 AM
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); :(2014-06-20 12:22 AM
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 ..
thanks2014-06-20 04:51 AM
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.2014-06-20 11:14 PM
2014-06-21 05:28 AM
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 required2014-06-22 10:19 PM
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 thanks2014-06-23 05:47 AM
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.....