I'm trying to enable the PC13 in the Blue Pill (stm32f103c8t6) which is connected to an LED, not sure if it is active low or active high so i tried both still doesn't work.
RCC->APB2ENR |= 0x10;
is used for enabling the clock in Port C.
GPIOC->CRH = (GPIOC->CRH & 0xFF0FFFFF) | 0x00100000;
is used to configure the port C to be in Output mode and Push-Pull.
GPIOC->ODR &= !(1<<13); is used to drive the C13 pin to LOW.
The whole code:
#include "stm32f10x.h"
int main(){
RCC->APB2ENR |= 0x10;
GPIOC->CRH = (GPIOC->CRH & 0xFF0FFFFF) | 0x00100000;
while(1) {
GPIOC->ODR = ~(1<<13);//if it is Active Low
for (int i = 0; i < 1000000; ++i) __asm__("nop");
GPIOC->ODR |= 1<<13; //if it is Active High
for (int i = 0; i < 500000; ++i) __asm__("nop");
}
}
Edit :
After some investigation, i discovered that the code is working perfectly if run a debugging session, could it be a software problem? or the code for debugging sets things i didn't ? and as i said, I'm using uVision to compile and flash.

