Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 10 months ago.
PwmOut sample code doesn't work on LED1 on STM32-L432KC
I have a Nucleo STM32-L432KC board.
I'm trying to build the example PwmOut sketch on mbed.com:
[code] Gradually change the intensity of the LED.
include "mbed.h" PwmOut led(LED1);
int main() { while(1) { led = led + 0.01; wait(0.2); if(led >= 1.0) { led = 0; } } } [/code]
This program is from the help page of the PwmOut object. (The only thing I changed was the == 1.0 to >= 1.0) When I download this and flash it with openocd, the LED does not light up.
When I use a simple DigitalOut program, the LED does light up, so presumably the flashing works right.
Download command: [code]openocd -f ./stm32-nucleo-l432kc.cfg -c 'program Downloads/Nucleo_blink_led.NUCLEO_L432KC.bin 0x08000000 reset exit'[/code]
1 Answer
5 years, 10 months ago.
The L432KC does not support the LED1(PB_3) as a PWM port.
Try to use PWM_OUT(PB_0) port for the PWM output.
Please refer to following pages;
https://os.mbed.com/teams/ST/code/Nucleo_pwm/file/c198a0f824eb/main.cpp/
https://os.mbed.com/users/mbed_official/code/mbed-dev/file/0387e8f68319/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/TARGET_NUCLEO_L432KC/PinNames.h/
https://os.mbed.com/users/mbed_official/code/mbed-dev/file/0387e8f68319/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/TARGET_NUCLEO_L432KC/PeripheralPins.c/