本帖最后由 siliconnect 于 2023-2-21 15:41 编辑
发现要SysTick_IRQHandler 1秒中断实现就不能
delay函数,否则config变调了。
用了delay可以了,实际改变了SysTick_Config的配置
如何才能 既可以中断 SysTick_IRQHandler
又可以 库函数那些delay10us, delay100us, delay1ms 都能同时用呢?
SysTick_Config(SystemCoreClock); //SystemCoreClock=4000000
void SysTick_IRQHandler(void)
{
; //1s中断
}
/**
* \brief delay100us
* delay approximately 100us.
* \param [in] u32Cnt
* \retval void
*/
void delay100us(uint32_t u32Cnt)
{
uint32_t u32end;
SysTick->LOAD = 0xFFFFFF;
SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk;
while(u32Cnt-- > 0)
{
SysTick->VAL = 0;
u32end = 0x1000000 - SystemCoreClock/10000;
while(SysTick->VAL > u32end)
{
;
}
}
SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk));
}
|