当前位置:网站首页>Stm32--- systick timer

Stm32--- systick timer

2022-07-05 08:16:00 chen_ bx

Systick Timer interrupt service function implementation LED Light out

mian Call in function SysTick_Config Function to configure timer ,SystemCoreClock Is frequency ,stm32f103 frequency 72M.
t=reload * (1/SystemCoreClock) Calculation time formula
SysTick_Config The parameter passed in the function is reload
SystemCoreClock = 72M,reload=72 when , t=72 * (1/72M)=1 us
SystemCoreClock = 72M,reload=72000 when , t=72000 * (1/72M)=1 ms
SystemCoreClock/1000 = 72000 = reload (1ms)

SysTick_Config(SystemCoreClock/1000);//1ms
//SysTick_Config(72000);

stay stm32f10x_it.c Find SysTick_Handler Write interrupt service function , Realization 500ms Flip LED state

void SysTick_Handler(void)
{
    
	static uint32_t i=0;
	i++;
	if(i>500){
    
		i = 0;
		LED_YELLOW_TOGGLE;
	}
}
原网站

版权声明
本文为[chen_ bx]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140545026399.html