片子, STR710f 外部中断的程序始下:
//XTI peripheral configuration ////================================================== void Set_XTI(void) { GPIO_Config(GPIO1, 0x4000, GPIO_IN_TRI_TTL); //
XTI_Init(); // XTI_LineModeConfig(XTI_Line8, XTI_FallingEdge); // XTI_LineConfig(XTI_Line8, ENABLE); // XTI_ModeConfig(XTI_Interrupt, ENABLE);
EIC_IRQChannelPriorityConfig(XTI_IRQChannel,3); //priority to 3 EIC_IRQChannelConfig(XTI_IRQChannel,ENABLE); // EIC_IRQConfig( ENABLE ); // }
///timer1 设定始下
//时间为100ms PWM void init_time1(void) { EIC->SIR[19] |= 0x00000001; // channel 19 priority 1 EIC->IER |= 1<<19; // Enable interrupt on channel 19 EIC->ICR |= 0x00000001; // Enable interrupts
TIM1->OCAR=5000/2 ; TIM1->OCBR=10000-5; TIM1->CR2 = 0x0800; // Enable interrupt and prescale=7 TIM1->CR2 |=19; TIM1->CR1 = 0x8000; // Enable counter TIM1->CR1 |=1<<4; //PWM TIM1->CNTR = 0x1000; // Any value written to this Reg results r }
///定时中断程序如下: void T1TIMI_IRQHandler(void) { TIM1->SR &= ~0x0800; //Clear the TIM1 interrupt flag while(1) //等候外部中断进入 {
time1_deal_bit=10; }
}
///////外部计数中断 void XTI_IRQHandler(void) {
//void XTI_IRQHandler(void) //{ u16 XTI_Pend; XTI_Pend = XTI_InterruptLineValue(); if (XTI_Pend & 0x0100) { XTI_PendingBitClear(0x0100); // Clear t } Display(8); //显示一个数字 }
我看了CPSR 的I F 标志都为0,请dx指点.
|