SysTick设置 void SysTick_Config(void) { /* Disable SysTick Counter */ SysTick_CounterCmd(SysTick_Counter_Disable); /* Disable the SysTick Interrupt */ SysTick_ITConfig(DISABLE); /* Configure HCLK clock as SysTick clock source */ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); /* SysTick interrupt each 1000 Hz with HCLK equal to 72MHz */ //SysTick_SetReload(9000); SysTick_SetReload(72000); /* Enable the SysTick Interrupt */ SysTick_ITConfig(ENABLE); } void SysTickHandler(void) { TimingDelay_Decrement(); } void TimingDelay_Decrement(void) { if (TimingDelay != 0x00) { TimingDelay--; } } void HALMG_IntPro( unsigned char nTime ) //假设传进来的nTime =100; { SysTick_CounterCmd(SysTick_Counter_Enable); TimingDelay = nTime; while( TimingDelay ) { HALMAG_SPITrackIntProc(); //这个自己定义的函数,可以不管 } /* Disable SysTick Counter */ SysTick_CounterCmd(SysTick_Counter_Disable); //在程序这设置断点后跟踪发现TimingDelay =100,在while里死循环,没有启用定时器中断,请问哪里出现问题了? /* Clear SysTick Counter */ SysTick_CounterCmd(SysTick_Counter_Clear); } |
RE:求助高手:STM32 使用SysTick作为定时器遇到的问题?
RE:求助高手:STM32 使用SysTick作为定时器遇到的问题?