how to setup clock when STM32CubeIDE empty project is used?
- March 26, 2020
- 4 replies
- 2969 views
hi All.
My name is Alfredo, I just have got a Blue_Pill_STM32F103C8 board.
I just installed STM32CubeIDE (Version: 1.3.0), i wrote a small project as toggle led using the CubeIDE configuration and everything is fine. but now i am trying to do the same thing using an empty project (it means, not using Cube configuration), after some hours, the project is compiled, and it is working if I debugged it using my ST-Link, so I can see the led on-off,running the program step by step (loading a var manually with a value to move the program forward), but when the debugger is disconnected, Led is not blinking anymore. I tested the program just setting the port and the led is ON, later i changed the program and I reset the port and the led is OFF.
I have never set the clock in my project, I do not how to do it (i was looking for this setting) but i could find it.
can you help please.
As i am using a for in order to spend time, I tested A<=5000000, A<=50000,A<=500,A<=5 and always the Led si ON or off
if the first line into main is GPIOC->BSRR = (1<<13); led is ON ( no toggle) and if it is GPIOC->BSRR = (1<<29); led is always OFF, it is like the program is not running after that....
here is the code used....(as i told you this is my firsts little program)
#include "stm32f10x_conf.h"
int main(void)
{
RCC->APB2ENR |= (1<<4); //1° Activamos el clock al Advanced Peripheral Bus, 2 porque ahi esta el GPIOC
GPIOC ->CRH |= ((1<<21)|(1<<20)); //2° definimos el MODE 11: Output mode, max speed 50 MHz.
GPIOC ->CRH &=~((1<<23)|(1<<22)); //2° definimos el CNFy 00: General purpose output push-pull
while (1)
{
GPIOC->BSRR = (1<<13); //bit 13 GPIOC_13 l3ed bit 13= SET Port bit set/reset register (GPIOx_BSRR
for (int a=0;a<=5000000;a++)
GPIOC->BSRR = (1<<29); // (13 + 16)bit GPIOC_13 led bit 29= RESET Port bit set/reset register (GPIOx_BSRR
for (int a=0;a<=5000000;a++)
{}
}
}
i guess this is the problem (not clock set), any comments it will be helpful.
I am sorry if the question is SO basic, but i am just starting with STM32.
br
Alfredo