Created
March 27, 2018 18:01
-
-
Save inkwisit/e88927f9b76655e07b6d3f83a3eeb78e to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
void delay(uint32_t); | |
int main() | |
{ | |
//Enabling the peripheral for the GPIOC in RCC sector | |
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; | |
//the led is connected to PC13 in Mini dev board. | |
//it would be push-pull configuration (Page = 160 and 171) | |
//CNF13[1:0] = 2'b00 | |
//bit 23 and 22 | |
//MODE13[1:0] = 2'b11 | |
//bit 21 and 20 | |
GPIOC->CRH |=(0<<23)|(0<<22)|(1<<21)|(1<<20); | |
//Now putting a initial value in the output data register (Page = 172) | |
//ODR is used as Read-Modify-Write manner | |
//BSRR is used as set and reset mode using only write mode , | |
//hence supporting atomic operations (Interrupt related) | |
GPIOC->ODR |= (1<<13); | |
while(1) | |
{ | |
//setting a bit set in PIN 13. (page = 172) | |
GPIOC->BSRR = (1<<13); | |
delay(1); | |
//setting a bit reset in PIN 13. (location bit = 29) | |
GPIOC->BSRR = (1<<29); | |
delay(1); | |
} | |
} | |
void delay(uint32_t seconds) | |
{ | |
uint32_t i = 0; | |
while(i<1500000) | |
{ | |
i++; | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment