版主,我在用K64的Pit的定时器,同过仿真发现定时器是在工作的,但是就是进不去中断,代码如下
void Pit_Init(PITn_e pitx ,uint32_t cnt)
{
SIM->SCGC6 |= SIM_SCGC6_PIT_MASK ; //ʹÄÜPITʱÖÓ
PIT->MCR &= ~PIT_MCR_MDIS_MASK; //¿ªÆôPITÄ£¿éʱÖÓ ,0ʹÄÜ£»1½ûÓÃ
PIT->MCR &= ~PIT_MCR_FRZ_MASK; //0£ºµ÷ÊÔģʽPIT¶¨Ê±Æ÷¼ÌÐøÔËÐУ»1£ºµ÷ÊÔģʽPIT¶¨Ê±Æ÷Í£Ö¹ÔËÐÐ
PIT_LDVAL(pitx) = cnt-1; //ÉèÖö¨Ê±ÆµÂÊ
PIT_TCTRL(pitx) = PIT_TCTRL_TIE_MASK; //ʹÄÜPITÖжÏÇëÇó
PIT_TCTRL(pitx) = PIT_TCTRL_TEN_MASK; //ʹÄÜPIT
NVIC_EnableIRQ(PIT0_IRQn);
NVIC_SetPriority(PIT0_IRQn,0);
}
void PIT0_IRQHandler(void)
{
PIT_Flag_Clear(PIT0);
T4_LED_Toogle;
}
|