LED at PA0
This commit is contained in:
parent
d272c110d0
commit
f973307870
|
@ -1,4 +1,8 @@
|
||||||
/* LED blink project for the STM32L031 */
|
/*
|
||||||
|
LED blink project for the STM32L011
|
||||||
|
|
||||||
|
Assumes LED at Pin 6, GPIO PA0
|
||||||
|
*/
|
||||||
|
|
||||||
#include "stm32l031xx.h"
|
#include "stm32l031xx.h"
|
||||||
|
|
||||||
|
@ -7,10 +11,11 @@ volatile unsigned long SysTickCount = 0;
|
||||||
void __attribute__ ((interrupt, used)) SysTick_Handler(void)
|
void __attribute__ ((interrupt, used)) SysTick_Handler(void)
|
||||||
{
|
{
|
||||||
SysTickCount++;
|
SysTickCount++;
|
||||||
|
|
||||||
if ( SysTickCount & 1 )
|
if ( SysTickCount & 1 )
|
||||||
GPIOA->BSRR = GPIO_BSRR_BS_13; /* atomic set PA13 */
|
GPIOA->BSRR = GPIO_BSRR_BS_0; /* atomic set PA0 */
|
||||||
else
|
else
|
||||||
GPIOA->BSRR = GPIO_BSRR_BR_13; /* atomic clr PA13 */
|
GPIOA->BSRR = GPIO_BSRR_BR_0; /* atomic clr PA0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -18,13 +23,15 @@ int main()
|
||||||
RCC->IOPENR |= RCC_IOPENR_IOPAEN; /* Enable clock for GPIO Port A */
|
RCC->IOPENR |= RCC_IOPENR_IOPAEN; /* Enable clock for GPIO Port A */
|
||||||
__NOP();
|
__NOP();
|
||||||
__NOP();
|
__NOP();
|
||||||
GPIOA->MODER &= ~GPIO_MODER_MODE13; /* clear mode for PA13 */
|
|
||||||
GPIOA->MODER |= GPIO_MODER_MODE13_0; /* Output mode for PA13 */
|
|
||||||
GPIOA->OTYPER &= ~GPIO_OTYPER_OT_13; /* no Push/Pull for PA13 */
|
|
||||||
GPIOA->OSPEEDR &= ~GPIO_OSPEEDER_OSPEED13; /* low speed for PA13 */
|
|
||||||
GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD13; /* no pullup/pulldown for PA13 */
|
|
||||||
GPIOA->BSRR = GPIO_BSRR_BR_13; /* atomic clr PA13 */
|
|
||||||
|
|
||||||
|
GPIOA->MODER &= ~GPIO_MODER_MODE0; /* clear mode for PA0 */
|
||||||
|
GPIOA->MODER |= GPIO_MODER_MODE0_0; /* Output mode for PA0 */
|
||||||
|
GPIOA->OTYPER &= ~GPIO_OTYPER_OT_0; /* no Push/Pull for PA0 */
|
||||||
|
GPIOA->OSPEEDR &= ~GPIO_OSPEEDER_OSPEED0; /* low speed for PA0 */
|
||||||
|
GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD0; /* no pullup/pulldown for PA0 */
|
||||||
|
GPIOA->BSRR = GPIO_BSRR_BR_0; /* atomic clr PA0 */
|
||||||
|
|
||||||
|
|
||||||
SysTick->LOAD = 2000*500 - 1;
|
SysTick->LOAD = 2000*500 - 1;
|
||||||
SysTick->VAL = 0;
|
SysTick->VAL = 0;
|
||||||
SysTick->CTRL = 7; /* enable, generate interrupt (SysTick_Handler), do not divide by 2 */
|
SysTick->CTRL = 7; /* enable, generate interrupt (SysTick_Handler), do not divide by 2 */
|
||||||
|
|
Loading…
Reference in New Issue