使用CAP1.0测频,上升沿捕获并产生中断,现在程序不能采集到数据,郁闷。main中测试是否采集BORDER_NUM 个数据,蜂鸣器未响,后将if( num==BORDER_NUM )一句注释掉,仍未响,说明没有跳出中断或者就没有进入中断,查了好久还没发现问题所在,还望高手提点一下!!!
程序如下: #define BORDER_NUM 17 static UINT16 num=0; static BOOL sgCapFinished = FALSE; static UINT32 counter[BORDER_NUM];
void __irq IRQ_Time1(void) // 中断程序 { T1IR = 0x10; if(sgCapFinished == FALSE ) { counter[num++] = T1CR0; if( num>BORDER_NUM-1) // { sgCapFinished = TRUE; T1CCR = 0x00; } } VICVectAddr = 0x00; }
void Timer1_Init( void ) { VICIntEnClr |= 0x20; num=0; sgCapFinished = FALSE; T1PR = 0; // 预分频为0 T1CCR = 0x05; // 上升沿捕获,产生中断 T1IR = 0x10; VICIntSelect = 0x00; VICVectCntl0 = 0x25; VICVectAddr0 = (UINT32)IRQ_Time1;
T1TCR = 0x03; T1TCR = 0x01; VICIntEnable |= 0x20; }
int main(void) { UINT32 i; Timer1_Init( ); while( sgCapFinished == FALSE ); // 等待 sgCapFinished == FALSE; num = 0; if( num==BORDER_NUM ) // 测试是否取到17个数据 PWM2_EnbleSound(2600); // 蜂鸣器响
Data_Process( counter ); // 数据处理 while(1); return 0; }
|