[Solved] How to use all available PWM for STM32

Mark81
Wed Dec 05, 2018 3:53 pm
I own a NUCLEO-F429ZI board, and here and here I found the pins’ map.

I wonder how to use all those PWM pins in my Arduino project. Should I use exactly those names? I.e.: `pinMode(PA_2_ALT0, OUTPUT);`


ag123
Wed Dec 05, 2018 4:09 pm
for this board, you would need to try STM’s stm32duino core or stm32generic core, libmaple core is unlikely to run on this board.

mrburnette
Wed Dec 05, 2018 4:09 pm
Mark81,

You should be using this Arduino “core”:
https://github.com/stm32duino/Arduino_Core_STM32

Much of the forum discussions around Roger’s core, GENERIC core, Blue_Pill, Maple_Mini will not be directly applicable to you.

However, your specific F4 board is not shown as up ported by default (yet) but new boards are added often. It is straight forward to build a variant for your board. See the WiKi:
https://github.com/stm32duino/wiki/wiki

Specifically:
https://github.com/stm32duino/wiki/wiki … nt-(board)

Ray


Mark81
Wed Dec 05, 2018 4:15 pm
[mrburnette – Wed Dec 05, 2018 4:09 pm] –
You should be using this Arduino “core”:
https://github.com/stm32duino/Arduino_Core_STM32

Yes, I’ve already added that repository to Arduino IDE and I found my board among the available models.


However, your specific F4 board is not shown as up ported by default (yet) but new boards are added often.

I’m not sure to understand: here a screenshot of my IDE with this model selected.

Clipboard 3.jpg
F429ZI
Clipboard 3.jpg (55.54 KiB) Viewed 259 times

mrburnette
Wed Dec 05, 2018 4:21 pm
[Mark81 – Wed Dec 05, 2018 4:15 pm] –


However, your specific F4 board is not shown as up ported by default (yet) but new boards are added often.

I’m not sure to understand: here a screenshot of my IDE with this model selected.

My bad. Things change quickly in this forum… :lol:


Mark81
Wed Dec 05, 2018 4:23 pm
No problem! Hence, I can use all that PWM pins with their names? I don’t want to use any other peripheral.

mrburnette
Wed Dec 05, 2018 4:35 pm
[Mark81 – Wed Dec 05, 2018 4:23 pm] –
No problem! Hence, I can use all that PWM pins with their names? I don’t want to use any other peripheral.

Consult your board schematic as STM often pre-configure hardware on some select pins. If the uC pin is “free”, you should be able to use as the pin map shows.

Ray


Mark81
Wed Dec 05, 2018 7:42 pm
mmm… There is something I still don’t understand.
Simplest example:

void setup()
{
analogWrite(PA_0, 180);
}


fpiSTM
Wed Dec 05, 2018 7:46 pm
All uncommented line are available for doing PWM:
https://github.com/stm32duino/Arduino_C … ins.c#L131

simply do a:
pinMode(PXy, OUTPUT);
analogWrite(PXy, <0 to 255>);

Warning: Use the pin number (PXy) not the pin name (PX_y).
analogWrite(PA0, 180);


Mark81
Wed Dec 05, 2018 8:07 pm
It still doesn’t work :cry:
I got a stable 3,3V on pin 28 of CN11 with:

//pinMode(PA0, OUTPUT);
analogWrite(PA0, 180);


fpiSTM
Wed Dec 05, 2018 8:21 pm
Seems strange, my last test works fine.
Which core version you used 1.4.0?
Did you try Pin 29 of CN10 for PA0 ?

Mark81
Thu Dec 06, 2018 4:34 am
Fixed… it was selected a older version of the Core :shock:
Updated to the latest (1.4.0) and rebuilt, now it works!
Thanks!

fpiSTM
Thu Dec 06, 2018 6:37 am
Ok. Seems strange as I did no stuff around this since a while.
Well one other unexplained behaviour…

Leave a Reply

Your email address will not be published. Required fields are marked *