STM32 CMSIS blink problems

hi
I faced with such problem: blink work in step by step debug mode
but when I trying run without debug, led light permanently without blinking

I use smt32f303re nucleo with onboard st-link and vscode platformio

what’s wrong?

P.S. with CubeIDE work fine

#include "stm32f303xe.h"

void delay (uint32_t time) {
    
    uint32_t i;
    for (i=0; i<time; i++) {}
    
}

int main (void) {
   

    RCC->AHBENR     |= RCC_AHBENR_GPIOAEN; //RCC ON

    GPIOA->MODER    |= GPIO_MODER_MODER5_0; //mode out
    GPIOA->OTYPER   = 0;
    GPIOA->OSPEEDR  = 0;
    
    while (1) 
    {

        GPIOA->ODR ^= GPIO_ODR_5;
        delay(1000000); 
  
 
    }
}

need to use volatile uint32_t i
all work fine, thx

1 Like