新手入门
- 积分
- 5
- 金钱
- 5
- 注册时间
- 2016-3-13
- 在线时间
- 0 小时
|
1金钱
ahp的时钟是72M的,将timer6 72分频到1M,计数10000下,使用示波器测量了下才7ms(实际应该是10ms左右),由于tim6只能使用内部时钟,是内部时钟不准的缘故吗?也不会这么不准吧?
代码如下:
[mw_shl_code=c,true] TIM6->SR=0;
//timer off
TIM6->CR1=0;
TIM6->PSC=((SystemCoreClock / 1000000) - 1);//so 10000clk is about 10ms
TIM6->ARR=clock;
TIM6->CNT=0;
TIM6->EGR=0;
//enable time,maybe we should set URS to 1?
TIM6->CR1=1;
//wait arrive time.
while(!TIM6->SR);
TIM6->SR=0; //clean sr[/mw_shl_code]
|
|