中级会员
 
- 积分
- 253
- 金钱
- 253
- 注册时间
- 2013-9-23
- 在线时间
- 44 小时
|
5金钱
我需要将定时器设置为单次定时模式,内部时钟,设置的定时时间假设是1秒左右。启动定时器后在大约400ms 强制停止计数器,再次启动定时器,发现600ms产生中断。
我希望每次启动,重装预置,都是1S延时时间。(不管是强制停止,还是溢出)
初始化TIM
TIM16->ARR=9000-1; //预置
TIM16->PSC=9000-1; //分频
TIM16->SMCR=0; //SMS[3:0]=0000, CK_INT 内部时钟
TIM16->DIER|=1<<0;
TIM16->CR1&=~(3<<5); //CMS[1:0]=00, 边缘对齐
TIM16->CR1&=~(1<<4); //DIR=0, 向上计数
TIM16->CR1 &= ~(1<<7); // 复位预装值
TIM16->CR1 |= (1<<3); // 单次计数
TIM16->CR1 |=0x01; // 使能
每次启动赋值 不管用没有装进出
TIM16->ARR=9000-1; // 装预置
TIM16->CR1 |=0x01; // 使能
似乎没有作用。
|
|