飞思卡尔K60中的PIT的链模式下CHN寄存器的使用k60pitchn寄存器
void PIT_ISR()//中断函数
{
static uint32_t i = 0;
GPIO_ToggleBit(HW_GPIOE,7);//小灯亮灭指示进入中断
printf("enter interrupt is %d\r\n",i++);//记录进入中断次数
PIT->CHANNEL[2].TFLG |= PIT_TFLG_TIF_MASK; //中断标志位清零
} int main(void)
{
static uint32_t fac_us = 0;
DelayInit();
/* 初始化PE6端口推完输出 /
GPIO_InitTypeDef GPIO_InitStruct1;
GPIO_InitStruct1.instance = HW_GPIOE;
GPIO_InitStruct1.pinx = 6;
GPIO_InitStruct1.mode = kGPIO_Mode_OPP;
GPIO_Init(&GPIO_InitStruct1);
/ 初始化PE7端口推完输出 /
GPIO_InitTypeDef GPIO_InitStruct2;
GPIO_InitStruct1.instance = HW_GPIOE;
GPIO_InitStruct1.pinx = 7;
GPIO_InitStruct1.mode = kGPIO_Mode_OPP;
GPIO_Init(&GPIO_InitStruct2);
/ 初始化串口UART0 */
UART_InitTypeDef UART_InitStruct1;
UART_InitStruct1.baudrate = 115200;
UART_InitStruct1.bitPerChar = kUART_8BitsPerChar;
UART_InitStruct1.instance = HW_UART0;
UART_InitStruct1.parityMode = kUART_ParityDisabled;
UART_Init(&UART_InitStruct1); PORT_PinMuxConfig(HW_GPIOD,6,kPinAlt3);
PORT_PinMuxConfig(HW_GPIOD,7,kPinAlt3); printf(" UART0 is ok\r\n"); SIM->SCGC6 |= SIM_SCGC6_PIT_MASK;//打开模块时钟
PIT->MCR &= ~PIT_MCR_MDIS_MASK; //打开模块
PIT->CHANNEL[2].TCTRL = PIT_TCTRL_TIE_MASK;/*打开中断同时清零其余寄存器*/
PIT->CHANNEL[2].TCTRL |= PIT_TCTRL_TEN_MASK;//PIT2定时器使能
PIT->CHANNEL[2].TCTRL |= PIT_TCTRL_CHN_MASK;//寄存器链模式开启
fac_us = GetClock(kBusClock);//读取总线频率
fac_us /= 1000000;
PIT->CHANNEL[2].LDVAL = fac_us*1000*1000;//中断周期1S
NVIC_EnableIRQ(PIT2_IRQn);//打开中断优先级
PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_TEN_MASK;//PIT1定时器使能
PIT->CHANNEL[1].LDVAL = fac_us*1000*2000;//中断周期2S
PIT_CallbackInstall(HW_PIT_CH2,PIT_ISR); //中断回调函数 while(1)
{
GPIO_ToggleBit(HW_GPIOE,6);//小灯亮灭指示系统运行
DelayMs(500);
}
} 请问为什么CHN没有起左右,PIT2和PIT1寄存器没有
连在一起,中断的周期时间没有变,还是PIT2的中断周期,求解答求解答
|