Created
October 16, 2014 04:14
-
-
Save reportingsjr/4e3696c565000a31bd0c to your computer and use it in GitHub Desktop.
STM32 hello world
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stm32f10x.h" | |
int main(void) { | |
int delay; | |
// Enable the clock for port C gpio | |
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; | |
// Configure port C, pin 8 as a push pull output | |
GPIOC->CRH = (GPIOC->CRH & 0xFFFFFFF0) | 0x00000002; | |
for(;;){ | |
// Set the LED as on for 500k cycles | |
for(delay = 0; delay < 500000; delay++) { | |
GPIOC->BSRR = (1 << 8); | |
} | |
// Set the LED as off for 500k cycles | |
for(delay = 0; delay < 500000; delay++) { | |
GPIOC->BRR = (1 << 8); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment