cancel
Showing results for 
Search instead for 
Did you mean: 

MCU : STM32F030F4 how can use PA2 output PWM ?

JLEE.1706
Associate II
 
9 REPLIES 9
Javierio
Associate III

Hello, it looks like PA2 is not connected to any PWM timer.

You could programm a (software) PWM using interruptions and toggling up and down the GPIO

Can you provide examples?

Because i am a new guy!!

can you use another pin?(maybe PA4)

What software are you using for developing in your PC?

I am sorry , i can only use PA2 .

I use keil uVision5

do you use cubeMX for the configuration?

why you can only use PA2?

maybe pictures of your board or code would help

JLEE.1706
Associate II

YES ,I use cubeMX for the configuration

but ,hardware is ready ,so i can't switch.

JLEE.1706
Associate II

you can see the picture , now pwm out is PB1

but i want switch to PA2

0690X00000AsWFfQAN.jpg

there is no PWM functionality in PA2.

PWM functionality is a feature some specific pins have, (because they can be connected to the timmer pwm outputs).

If the pin you want to use doesnt have that access to the pwm timmer function you need to create your own pwm thing.

How to do it:

Select your timmer in cubeMX, start the timmer as compare and match interruption.

Inside the ISR(interruption function) of the timmer you just configured put some gpio_toggle function or counters.

The rest is just playing around with it

you can see the functionalities of the PB1 or PA2 pin if you leftclick on it.

PB1 has the Timmer channel 1 functionalities (like pwm and more)0690X00000AsWMWQA3.png

PA2 is only linked with ADC, UART, and GPIO functionalities0690X00000AsWLnQAN.png