Created
December 12, 2014 15:09
-
-
Save JulioAlexanderAguilarAngulo/13d1754b45c37b7aff59 to your computer and use it in GitHub Desktop.
STM32 Tutorial 001a: Blinking a led
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
/*************************************** STM32 Tutorial v.2015 | |
Authors: Julio Alexander Aguilar Angulo. [email protected] | |
Elodie Pauly. [email protected] | |
(c) ISEN-TOULON. 2015. www.isen.fr | |
*******************************************************************************/ | |
/**** Tuto 01a: Blinking a LED (and using registers and bit masking )**********/ | |
/******************************************************************************/ | |
#include "stm32l1xx.h" // prototypes and intrinsic declarations | |
/* Testboard: STM32L152 NUCLEO */ | |
/**** Hardware to use on this Tutorial: Onboard USER LED ( on PA5 ) **********/ | |
#define LED 1<<5; // Mask to map that LED | |
/*** Variable declarations ************************************************/ | |
int i; | |
/* Private function prototypes -----------------------------------------------*/ | |
void Initsyst(void); | |
/* Code Starts Here!! ********************************************************/ | |
/* note: iar internals configure the system clock to 32 MHz */ | |
void main() | |
{ | |
Initsyst(); | |
GPIOA->ODR &= ~LED;// turn off led as initial condition | |
while (1) | |
{ | |
GPIOA->ODR^=LED; // blink the led | |
for(i=0;i<=100000;i++) // Software Delay | |
{ | |
} | |
} | |
} | |
/***** Private Functions Definition **********************************/ | |
void Initsyst(void) | |
{ | |
RCC->AHBENR|=0x01;// affect clock to GPIOA | |
GPIOA->MODER|=0x5555;// output mode | |
GPIOA->OTYPER&=0x0000; // push pull | |
GPIOA->OSPEEDR|=0xFFFF;// High speed out | |
GPIOA->PUPDR&=0x0000; // no pullup | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment