2015-02-18 02:50 PM
Hello,
I am programming Timer 3 for PWM mode. Please see the attached image. The yellow trace is Timer 3, the green is Timer 4, which follows Timer 3 by a period of 180 degrees shift. The top PWM train (Timer 3) seems to want to momentarily go high for about 100ms then low, and it doesn't agree with anything I am programming it for. There are supposed to be exactly 4 pulses at this frequency, which there are - however, that first initial 100ms pulse is not supposed to be there. You can see that Timer 4 (green) follows Timer 3, including the initial pulse - which can be expected. I can post some code, but perhaps someone has experienced something like this before, or knows why it might be doing this. All the other pulses are perfectly fine, and behave exactly as expected. If I insert a break right at the Timer 3 interrupt clear, the very first interrupt, before it's had a chance to process the interrupt, the scope trace shows the output pin for Timer 3 pin is HIGH, which does not make sense, as it's set as a ''GPIO_PuPd_NOPULL'', the same as Timer 4's pin, and that pin initializes and is low at the start. It's a bit confusing as it doesn't appear to be related to the timer, but the pin configuration, yet both Timer 3 and 4 pins are configured exactly the same. Any suggestions would be appreciated - thank you. #timer-3-pwm2015-02-19 12:16 AM
> I can post some code
Do so. This most probably has nothing to do with GPIO setup. JW2015-02-19 08:04 AM
2015-02-20 03:42 AM
> TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Disable);
> TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Disable);
RM0090, comment under TIMx_CCMR1.OC1PE bit description: 2: The PWM mode can be used without validating the preload register only in one- pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed. Similarly, in RM0090, 18.3.9 PWM mode: You must enable the corresponding preload register by setting the OCxPE bit in the TIMx_CCMRx register [...] So, enable preload, and if needed, force update through setting TIMx_EGR.UG (surely there is a function in the ''library'' for that, but I don't speak the library gobbledygook). JW PS. Don't cross-post; but if you must so, place a link in both instances to point to the other.2015-02-20 03:47 AM
One more thing, did you check if those pins don't collide with on-board peripherals on the DISCOVERY board?
JW2015-02-20 09:26 AM