rogerclarkmelbourne / Arduino_STM32

Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards
Other
2.5k stars 1.26k forks source link

PWM does not work on STM32F407VET6 #859

Closed ghost closed 8 months ago

ghost commented 2 years ago

Hey! I am using STM32F407VET6 board: https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0 According to the scheme, LEDs are connected to pins PA6 and PA7. I tried to control them using PWM. But nothing happened. There is no PWM signal. The LEDs are either on or off. Here is some sample code I used:

void setup() {
    pinMode(PA6, PWM);  // setup the pin as PWM
}

void loop()  {
    for (int fadeValue = 0; fadeValue <= 65535; fadeValue += 1280) {
        pwmWrite(PA6, fadeValue);
        delay(30);
    }
    for (int fadeValue = 65535 ; fadeValue >= 0; fadeValue -= 1280) {
        pwmWrite(PA6, fadeValue);
        delay(30);
    }
}

I tried analogWrite instead of pwmWrite, but it didn't affect anything. I've tried some other pins as well. But PWM doesn't work anywhere. Can you fix this somehow?