//源文件 void TimerPhyConfig() { RCC->APB1ENR |= (1<<1); //使能Timer3 TIM3->ARR = arr; TIM3->PSC = psc; TIM3->DIER = (1<<0); //Update interrupt enabled TIM ...
//源文件 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(); /**********************************************************************/