본문 바로가기

hardwares/stm32

Nucleo-F411RE 내장 LED 깜빡이기 - BSRR

전체 보기 : https://makershackers.tistory.com/tag/baremetal_stm32_f411

 

 

 

#include "stm32f4xx.h"

void DelayMilliseconds (int delay);

int main(void)

  {
   RCC->AHB1ENR |= 1;
   GPIOA-> MODER |= 0x400;
   
   while (1) {
         GPIOA -> BSRR |= 0x20; // GPIOA -> ODR |= 0x20; // set PA5 high
         DelayMilliseconds(100);
         GPIOA -> BSRR = 0x00200000; // 0b 00000 0000 0010 0000 0000 0000 0000 0000 
         DelayMilliseconds(100); 
        }
  }

// Taking into account 16Mhz system clock

void DelayMilliseconds (int delay)
{
 int i;
 for(;delay>0;delay--) {
  for (i=0;i<3195;i++);
  }
}