Hi ,
My simple blink led code is not after build and upload . But its working only after “Start Debugging” . How to make the code to run just after upload
[env:nucleo_f446re]
platform = ststm32
board = nucleo_f446re
framework = stm32cube
Thanks
Baburaj
Please show the complete code.
This following is the bare meal code
#include <stm32f4xx.h>
#define RCC_GPIOAEN (1U<<0)
#define GPIOA_MODER5_10 (1U<<10)
#define GPIOA_MODER5_11 (1U<<11)
int main(void)
{
RCC->AHB1ENR |= RCC_GPIOAEN ;
GPIOA->MODER |= GPIOA_MODER5_10 ;
GPIOA->MODER &= ~GPIOA_MODER5_11 ;
while (1)
{
GPIOA->BSRR = (1U<<5) ;
for (int i=0;i<1000000;i++){}
GPIOA->BSRR = (1U<<21) ;
for (int i=0;i<1000000;i++){}
}
}
Delays like these are optimized away on the default -Os
setting. No wonder your code works in debug mode, which uses -Og
(optimize for debug). Put a asm volatile("nop");
statement inside each loop.
Hi ,
Thanks . It works now .
I was spending lot of time with platformio.ini
Seems i have to learn a lot !
Thanks again !