Blinking a LED in STM32F103C8T6 (Blue Pill) Board

1) First Include STM32F103xB_CUBELIB and cmsis_core in the project

#include "stm32f1xx.h"

void waitForAmoment(int Moment)
{
volatile int i,j;
for (i = 0; i < Moment; ++i)
{
j++;
}
}

int main(void)
{
//Enable the GPIO Clock by AHB and RCC
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
GPIOC ->CRH |= GPIO_CRH_MODE13; //PC13 in output mode, 50 MHz
GPIOC->CRH &= ~(GPIO_CRH_CNF13); //PC13 General Purpose Output, Push Pull Config

    while(1)
    {
    GPIOC->BSRR |= GPIO_BSRR_BS13;
    waitForAmoment(1000000);
    GPIOC->BRR |= GPIO_BRR_BR13;
    waitForAmoment(1000000);
    }
}


Comments

Popular posts from this blog

HackRF with srsLTE and openlte

Read Continuously from Serial Port in QT