论坛元老
 
- 积分
- 3071
- 金钱
- 3071
- 注册时间
- 2018-2-7
- 在线时间
- 285 小时
|
发表于 2018-2-7 16:17:38
|
显示全部楼层
void TIM1_Init( void )
{
// 16分频 16M/(0x0f+1)=1M CNTR计数一次为 1/1M=1us 定时1000us
TIM1_TimeBaseInit( 0x0f, TIM1_COUNTERMODE_UP, 1000, 0 );
TIM1_ClearFlag( TIM1_FLAG_UPDATE );
TIM1_ITConfig( TIM1_IT_UPDATE, ENABLE ); // 使能更新中断
enableInterrupts(); // 使能全局中断
}
INTERRUPT_HANDLER( TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11 )
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
TIM1_ClearITPendingBit( TIM1_IT_UPDATE );
time1_num--;
if( 0 == time1_num )
{
TIM1_Cmd( DISABLE );
time1_Flag = 1;
}
} |
|