platformio / platform-ststm32

ST STM32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/ststm32
Apache License 2.0
405 stars 312 forks source link

nucleo STM32H7 framework cmsis #620

Closed aleuarore closed 2 years ago

aleuarore commented 2 years ago

I'm trying to set up the example cmsis-blink on NUCLEO-H743ZI2 but I don't get success. When I debug, the loop runs well but the LED doesn't blink. Any idea?

aleuarore commented 2 years ago

STM32H743 has GPIO port mode register set to Analog mode = 11. To set the mode register to 01 we have to clean the first bit.

examples/cmsis-blink/main.c

...

int main(void)
{
    ENABLE_GPIO_CLOCK;              // enable the clock to GPIO
    LEDPORT->_MODER &= ~GPIO_MODER_MODE0; // Add this line!!!!!!!
    LEDPORT->_MODER |= GPIOMODER;   // set pins to be general purpose output
    for (;;) {
    ms_delay(500);
    LEDPORT->ODR ^= (1<<LED1);  // toggle diodes
    }

    return 0;
}