BL0061+STM32F401 PWM bug

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

BL0061+STM32F401 PWM bug

Post by fotios »

Hi everyone
With the help of Ben we have debugged the digital I/O ports and the LCD display so far.
Now we have to debug the PWM functionality of micro.
The output is TIM1_CH1 assigned to the pin 41 (PA8) of STM32F401 and connected to the bus F6 of BL0061.
Here the fcf:
PWM_STM.fcfx
(11.3 KiB) Downloaded 114 times
Best Regards FOTIS ANAGNOSTOU

User avatar
Benj
Matrix Staff
Posts: 14837
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: BL0061+STM32F401 PWM bug

Post by Benj »

Hi Fotios,

Is this still in Flowcode v7, just confirming before I dive in :wink:

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: BL0061+STM32F401 PWM bug

Post by fotios »

Hi Ben
Yes, still in FC v7.
Do you think that would be better, for both of us :wink:, an upgrade to FC v8?
Thanks a lot
Best Regards FOTIS ANAGNOSTOU

User avatar
Benj
Matrix Staff
Posts: 14837
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: BL0061+STM32F401 PWM bug

Post by Benj »

No v7 is fine, I just have to be sure so I'm not testing using the wrong version.

The fix will likely be rolled out to both anyway so I wouldn't worry.

I've managed to improve the previous LCD fix for you now too which is great. The problem was caused because when we output a 0 on the enable pin the pin was being converted to an input and then back to an output which was causing a glitch and causing the LCD drive firmware to register a false enable strobe. Now we mask off the DDR better so that an output stays as an output and hence no glitch.

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: BL0061+STM32F401 PWM bug

Post by fotios »

Hi Ben
:D
Best Regards FOTIS ANAGNOSTOU

User avatar
LeighM
Matrix Staff
Posts: 2043
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: BL0061+STM32F401 PWM bug

Post by LeighM »

Hi,
Fixed file attached, to go into Flowcode v7 CAL\STARM directory.
V8 version to be pushed out later.
Attachments
STARM_CAL_PWM.c
(8.25 KiB) Downloaded 65 times

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: BL0061+STM32F401 PWM bug

Post by fotios »

Hello Leigh
Yes, the new CAL file is correct and works flawlessly. :D
The bug is fixed.
A big thank for your effort.
By the chance given, the formula to calculate the period of a PWM is:

Period = [ Prescaler X ( Period Register + 1 ) ] / [ 4 X Fosc ]. For period expressed in seconds, the Fosc should be placed in Hz.

Please don't forget that all available channels offered by the same timmer, also share the same period. Only the duty cycle can be changed in each channel.

There is only a small error on FC7 simulator regarding the Duty Cycle? For e.g. DC=50%, if Period Register is loaded with 62499 then DC=62499/2=31249. On actual hardware that works correctly but the simulated PWM shows DC=12.49%.
Please see in attached FCF
PWM_STM.fcfx
(12.54 KiB) Downloaded 68 times

Many thanks again for the support.
Best Regards FOTIS ANAGNOSTOU

Post Reply