//源文件 void TimerPhyConfig() { RCC->APB1ENR |= (1<<1); //使能Timer3 TIM3->ARR = arr; TIM3->PSC = psc; TIM3->DIER = (1<<0); //Update interrupt enabled TIM3->CR1 |= (1<<0); //Counter enabled TIM3->CR1 &= ~(1<<4); //Counter used as upcounter HAL_NVIC_EnableIRQ(TIM3_IRQn); } void TIM3_IRQHandler(void) { if(TIM3->SR&0X0001)//溢出中断 { LD1_TURN; LD2_TURN; LD3_TURN; } TIM3->SR&=~(1<<0);//清除中断标志位 } //头文件 /*****************************timer************************************/ #define SET500MS #ifdef SET500MS #define arr (5000-1) #define psc (10800-1) #endif #ifdef SET1000MS #define arr (5000-1) #define psc (10800-1) #endif void TimerPhyConfig(); /**********************************************************************/
标签:TIM3,timer,TURN,1CR1,nulceo144,STM32F6xx From: https://www.cnblogs.com/lum0126/p/16883412.html