看到 ucos 的节拍控制 它的设定函数是这样的#define OS_TICKS_PER_SEC 1000
OS_CPU_SysTickInit(OS_TICKS_PER_SEC);
函数代码如下
#define OS_CPU_CM0_NVIC_ST_RELOAD (*((volatile INT32U *)0xE000E014uL)) /* SysTick Reload Value Reg. */
void OS_CPU_SysTickInit (INT32U cnts)
{
INT32U prio;
OS_CPU_CM0_NVIC_ST_RELOAD = cnts - 1u;
prio = OS_CPU_CM0_NVIC_PRIO_ST;
prio &= ~(OS_CPU_CM0_NVIC_PRIO_MIN);
prio |= OS_CPU_CM0_NVIC_PRIO_MIN;
/* Set prio of SysTick handler to min prio. */
OS_CPU_CM0_NVIC_PRIO_ST = prio;
/* Enable timer. */
OS_CPU_CM0_NVIC_ST_CTRL |= OS_CPU_CM0_NVIC_ST_CTRL_CLK_SRC | OS_CPU_CM0_NVIC_ST_CTRL_ENABLE;
/* Enable timer interrupt. */
OS_CPU_CM0_NVIC_ST_CTRL |= OS_CPU_CM0_NVIC_ST_CTRL_INTEN;
}
感觉这样设置不对的样子,感觉应该是
OS_CPU_CM0_NVIC_ST_RELOAD = 时钟源/cnts-1;
对stm32f051 不熟悉 求教
|