My Environment:
1- Mac Os
2- STM32 Bluepill flashed with Blackmagic Prob firmware and acts as a Black magic probe
3- Stm32 Bluepill as a development board
4- CMSIS Frameworks
My Problem:
I am trying to program my STM32 blue pill and debugging it using a Blackmagic probe (a bluepill with BMP firmware)
I wrote the following code and when debugging it using BMP it starts getting executed but when reaching the delay1() function line of code, control just passes it and doesn’t execute it therefore the LED connected to the pin PB11 is always ON but dimmed because it gets switched ON and Off so fast and the delay function is not executed!
My question is:
What is going on? Why would control just jump and not execute a line of code?
/**
* ? LED BLINKIND SKETCH, PINOUT FOR STM32F103XX
* ! Green LED -> PB11
* * Blue LED -> PB10
* * Red LED -> PB1
* * Pot. -> PA0
* * Push Btn. -> PB9
*/
//? ========= INCLUEDS =+=========
#include "STM32F1xx.h"
//? ========= PROTOTYPES ===========
void portsInit(void);
void delay1(void);
int main(void)
{
portsInit();
while(1)
{
//GPIOB->ODR ^= GPIO_ODR_ODR11_Msk;
GPIOB->BSRR = GPIO_BSRR_BS11;
delay1();
GPIOB->BSRR = GPIO_BSRR_BR11;
delay1();
}
}
void portsInit(void)
{
//* Enable clock to port "A" and "B" (Default SysCLK = 8Mhz ext. OSC):
RCC->APB2ENR |= ((1<<2) | (1<<3));
//* Set Pin Modes and Pin Configuration. (Reset Value = 0x4444 4444)
//! Setting Mode for Pin PB11 MODE[1:0], "Bit1" of the MODE register = 1 and "Bit0" = 1
GPIOB->CRH |= GPIO_CRH_MODE11_Msk; // Set PB11 MODE as Output @ 50Mhz (max).
//! Setting Configuration for Pin PB11 CNF[1:0]
GPIOB->CRH &= ~(GPIO_CRH_CNF11_Msk);
/*
* Final GPIOB->CRH register must equal 0b 0011 0100 0100 0100 or 0x3444,
* to set pb11 pin as an Output MODE @ 50Mhz configured as General purpose
* output push-pull configuration.
*/
}// End portsInit() Function.
void delay1(void)
{
for(uint32_t i = 0; i < 10000000; i++)
{
//! LOOP DOING NOTHING WASTING TIME (PSUDO-DELAY)
}
}
/** ============= Registers Can be used as well such as: ==================
//RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; // Enable PortA Clock
//RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // Enable PortB Clock
Set pin "PB11" as output push-pull (Green LED)
GPIOB->CRH |= ((1<<12) | (1<<13)); //Set Pin to Output 50Mhz max speed
GPIOB->CRH &= ~((1<<14) | (1<<15)); //Configure Pin as Push-Pull
*/
PS. I am using an extension for commenting!