/**
******************************************************************************
* @file : main.c
* @author : Fernando Hermosillo Reynoso
* @brief : Main program body
******************************************************************************
*/
#include <stdint.h>
#include "stm32f103xb.h"
void delay_ms(uint16_t ms) {
volatile unsigned long t = 0;
for(uint16_t i = 0; i < ms; i++)
{
for(t = 0; t < 800; t++);
}
}
int main(void)
{
// Enable GPIOC clock
RCC->APB2ENR |= 1UL << 4;
// Set PC13 as 2MHz push-pull output
GPIOC->CRH &= ~(0x0FUL << 20); // MODE13=00, CNF13=00
GPIOC->CRH |= 1UL << 21; // MODE13 = 10 (2MHz output)
// Loop
while (1)
{
GPIOC->ODR ^= (1UL << 13); // Set to zero
delay_ms(500);
}
}
Loading
stm32-bluepill
stm32-bluepill