본문 바로가기

hardwares/stm32

SysTick 시간기기(timer) (2/2), 1초 이상

SysTick 시간기기(timer) 편 강의 입니다. 

 

 

 

 

 

 

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

 

 

template_002_makershackers_systick_wo_movie.pptx
9.17MB

 

 

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

 

 

tick

 ① 째깍거리다, 똑딱거리다
 ② 똑딱거리는 소리, 재깍거리는 소리

timing

 ① 시기 선택,  속도를 맞추는, 적절한 시기를 찾아내는 기술, 시간을 잘 맞춤 

 ② 박자, 박자 감각

time

어떤 시각에서 어떤 시각까지의 사이

 

#include "stm32f4xx.h"

void delay_milliseconds_using_system_tick(int mills);


int main (void)
{
	(*RCC).AHB1ENR |= 1;
	(*GPIOA).MODER |= 0x400;
     while(1)
     {
    	 delay_milliseconds_using_system_tick(2000);
    	 (*GPIOA).ODR ^= 0x20;
     }
}

void delay_milliseconds_using_system_tick(int mills)
{

	(*SysTick).LOAD = 16000-1;  // Reload with number of clocks per millisecond
	(*SysTick).VAL = 0;      // Clear current value register
	(*SysTick).CTRL = 0x5;   // System Tick을 사용함

    for (int i =0; i<mills;i++)
   {
    // wait until the count flag is set
    while((SysTick->CTRL & 0x10000)==0){}
   }
    SysTick -> CTRL = 0;
}