STM32F0(4)定時(shí)器中斷
void Time3_Init(void) // 1ms 中斷定時(shí)器初始化
{
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // 打開對(duì)應(yīng)外設(shè)的時(shí)鐘
NVIC->ISER[0] |= (1 << TIM3_IRQn);
NVIC->IP[TIM3_IRQn / 4] |= (0x000000c0 << (8 * (TIM3_IRQn % 4)));
TIM3->DIER |= (1 << 0);
TIM3->PSC = 35;
TIM3->CNT = 1000;
TIM3->ARR = 1000;
TIM3->CR1 |= (1 << 0);
}
void TIM3_IRQHandler(void) // 中斷服務(wù)程序
{
TIM3->SR &= ~(1 << 0); // 手動(dòng)清除標(biāo)志位
// ...
}