10 years ago.

Nucleo_pwm

What is this basic program supposed to do?

On my board (F030R8), LD3 is permanently on (Red) and LD2 flashes green at a rate of about 1 second on and 1 second off.

1 Answer

10 years ago.

LD2 is connected to port PB12 on the F302 board and PA5 on the L152 board. This program configures the appropriate port connected to LD2 to output a fixed duty cycle pulse width with period defined by mypwm.period and duty cycle (on tine) defined by mypwm.pulsewidth. You can change either of these parameters using the MBED compiler and see the results. This program also uses the virtual com port to send a message to your terminal if you are using a terminal program like hyperterm. Every time you press the black reset button, the Nucleo will send "pwm set to 10%" to the terminal, demonstrating mypwm.read command and how the printf instruction can be used for program debugging purposes. The Red LED, LD3 is connected to the power supply and indicates the presence of +5V at the U4 regulator input.

The iniial pwm values are set in the following two lines of code.

mypwm.period_ms(10); mypwm.pulsewidth_ms(1);