void __irq IRQ_Time0(void) { Out_Counter = 1; T0IR = 0x01; // 清除中断标志 VICVectAddr = 0x00; // 通知VIC中断处理结束 T0TCR = 0x03; // 启动并复位T0TC T0TCR = 0x01; } void Time0Init(void) { /* Fcclk = Fosc*4 = 11.0592MHz*4 = 44.2368MHz Fpclk = Fcclk/4 = 44.2368MHz/4 = 11.0592MHz */ PINSEL0 |= 0x20; //p0.2 T0PR = 0; // 设置定时器0分频为100分频,得110592Hz T0CCR = 0x20; T0TC = 0; T0TCR = 0x01; /* 设置定时器0中断IRQ */ VICIntSelect = 0x00; // 所有中断通道设置为IRQ中断 VICVectCntl0 = 0x24; // 定时器0中断通道分配最高优先级(向量控制器0) VICVectAddr0 = (uint32)IRQ_Time0; // 设置中断服务程序地址向量 VICIntEnable = 0x00000010; // 使能定时器0中断 } |