BL0061+STM32F401 PWM bug

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

Moderators: Benj, Mods

User avatar
fotios
Posts: 409
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 82 times
Been thanked: 100 times
Contact:

BL0061+STM32F401 PWM bug

Postby fotios » Mon Jun 04, 2018 9:27 am

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 71 times
Best Regards FOTIS ANAGNOSTOU

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: BL0061+STM32F401 PWM bug

Postby Benj » Mon Jun 04, 2018 10:12 am

Hi Fotios,

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

User avatar
fotios
Posts: 409
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 82 times
Been thanked: 100 times
Contact:

Re: BL0061+STM32F401 PWM bug

Postby fotios » Mon Jun 04, 2018 12:02 pm

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: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: BL0061+STM32F401 PWM bug

Postby Benj » Mon Jun 04, 2018 12:46 pm

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.
These users thanked the author Benj for the post:
fotios (Mon Jun 04, 2018 6:51 pm)
Rating: 5.26%
 

User avatar
fotios
Posts: 409
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 82 times
Been thanked: 100 times
Contact:

Re: BL0061+STM32F401 PWM bug

Postby fotios » Fri Jun 08, 2018 8:00 am

Hi Ben
:D
Best Regards FOTIS ANAGNOSTOU

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: BL0061+STM32F401 PWM bug

Postby LeighM » Fri Jun 08, 2018 1:04 pm

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.52 KiB) Downloaded 36 times
These users thanked the author LeighM for the post:
fotios (Sat Jun 09, 2018 6:03 am)
Rating: 5.26%
 

User avatar
fotios
Posts: 409
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 82 times
Been thanked: 100 times
Contact:

Re: BL0061+STM32F401 PWM bug

Postby fotios » Sat Jun 09, 2018 8:40 am

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 36 times



Many thanks again for the support.
Best Regards FOTIS ANAGNOSTOU