消息关闭
    暂无新消息!

stm32 systick

问题作者 : Oxley2017-07-29发布
#include "led.h"
#include "stm32f10x.h"

static __IO uint32_t TimingDelay;

void systick_init(void){
if(SysTick_Config(SystemCoreClock/100000))
{
while(1);
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}

void delay( u32 nTime){
TimingDelay = nTime;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
while(TimingDelay !=0)
;
}

void TimiDelay_Decrement(void){
if(TimingDelay!=0x00){
 TimingDelay--;

}
 
void SysTickHandler(void){
TimiDelay_Decrement();
}

int main(void){
LED_Init();
systick_init();
while(1)
{
LED=0;
delay(500);
LED=1;
delay(500);
}
}
功能是想要精确延时,让led闪烁,可是没有出现想要的现象,一直亮着;求助大神
 

3个回答

︿ 1
delay( u32 nTime){
TimingDelay = nTime;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
while(TimingDelay !=0)
;
}
少了个--吧?