STM32 PWM Disable ??

An area to discuss ARM specific problems and examples

Moderator: Benj

Post Reply
User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

STM32 PWM Disable ??

Post by fotios »

Hi everyone

I use a PWM channel to blink an LED at a rate of ON=0.5sec / OFF=0.5sec.
With Period=23438, prescaler=1024, and Duty=11719 the above is accomplished (for SysCLK=24MHz as is the default FC7 setting).
The sequence is:
1. PWM Enable
2. Set Duty cycle 10bit

Later I want to terminate this PWM, i.e. "PWM Disable".
On FC7 simulation is working OK.
It is not working on actual hardware.
I've tried it on all PWM channels and the command "PWM Disable" does not take effect. The PWM if is enabled is continuously working and can't be disabled.
Should we get the tricky way? I.e. configuring the PWM output pin as general input instead of PWM disable, it can also stop the PWM.

Thanks
Best Regards FOTIS ANAGNOSTOU

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 PWM Disable ??

Post by LeighM »

Thanks, I will have a look into it

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: STM32 PWM Disable ??

Post by fotios »

Hi
Actually I haven't problem with Disable PWM as I found out that, for my application instead of disabling it is better to change the duty cycle to "0" (LED off) and again back to "11719" (LED blinks 0.5sec). In this way, the code runs faster.
However, it is good to fix this bug if exists.

Thanks
Best Regards FOTIS ANAGNOSTOU

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 PWM Disable ??

Post by LeighM »

Thanks.
I'm just looking at this now.
btw. Do you get a compile error with the PWM?
What device are you using? F303?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 PWM Disable ??

Post by LeighM »

Here is an updated CAL file with PWM disable function (for Flowcode V7) ...
Attachments
STARM_CAL_PWM.c
(8.82 KiB) Downloaded 355 times

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: STM32 PWM Disable ??

Post by fotios »

Hi
The new file works flawlessly and thank you.
Answering to your questions:
I had never a compiler error with the old file.
I have an application board equipped with the STM32F303RE - QFP64 which I try to program and on which I make all of the tests.
BTW, I did the selection of this micro because of the offered 4 independent ADC converters and the 8 individual Timers.
As a side note, and having previous experience only with 8-bit PICs and few 8-bit AVRs, I'm very impressed with the ADC speed and the accuracy of this ARM-M4 so far.

Thanks
Best Regards FOTIS ANAGNOSTOU

Post Reply