cc3200 定时器捕获 进中断
时间:10-02
整理:3721RD
点击:
你好!我在Timer_cc中基础上改变的例子:这里我用Timer3_A 作为红外捕获,Timer3_B 作为溢出。在捕获中断里面打开溢出中断,可是如果我不用Reprot语句输出一些东西的话,就无法进入Timer_B的溢出中断,Report语句执行的不够多的话,可以进入Timer_B的溢出中断函数,可是捕获到的数据就是错误的,我尝试这更改 MAP_TimerLoadSet(TIMERA3_BASE, TIMER_B, 60000); 的值,也没有得到什么结果,如果有什么解决方法,请指点一下,谢谢。
static unsigned long g_ulSamples[90]; static unsigned long g_ulFreq = 0 ; static int i, j, timeStatus = 1;//i->enter cap times j-> test timeout timestart->time_b start static void TimerIntHandler() { MAP_TimerIntClear(TIMERA3_BASE,TIMER_CAPA_EVENT); g_ulSamples[g_ulFreq++] = MAP_TimerValueGet(TIMERA3_BASE,TIMER_A); // Report("cap==en g_ulFreq: %d \r\n\n",g_ulFreq); // Report("Samples[%03d] = %04ld i: %d\r\n",g_ulFreq,MAP_TimerValueGet(TIMERA3_BASE,TIMER_A),i++); // if(g_ulFreq >= 40){ // MAP_TimerDisable(TIMERA3_BASE, TIMER_A); // for(; j<g_ulFreq ;j++){ // Report("i:%4d %03ld %03ld ",i++ ,g_ulSamples[j] , g_ulSamples[j+1]); // Report("Width: %03dms \r\n ",(g_ulSamples[j] - g_ulSamples[j+1])/800); // } //// g_ulFreq = 0; // } // Report("timeStatus: %d i: %d \r\n\n",timeStatus,i++); // if(timeStatus == 1){ // MAP_TimerLoadSet(TIMERA3_BASE, TIMER_B, 60000); // MAP_TimerEnable(TIMERA3_BASE,TIMER_B); // timeStatus = 0; // } MAP_TimerEnable(TIMERA3_BASE,TIMER_B); //这里我想要给TIMER_B 重新赋值,保证最后接收完毕后能够退出接收 //如果上面的循环输出注释掉,下面的语句不注释掉,可以进入溢出中断,但接收到的红外波长就不正确 //如果将Report语句全部注释掉就不会进入TIMER_B的溢出中断 // TimerValueSet(TIMERA3_BASE, TIMER_B,0); // Report("time_B SET:%ld\r\n\n",MAP_TimerValueGet(TIMERA3_BASE,TIMER_B)); } static void TimerIntHandler_TIME_OUT(){ MAP_TimerIntClear(TIMERA3_BASE,TIMER_TIMB_TIMEOUT); TimerDisable(TIMERA3_BASE, TIMER_A); Report("enter timeout \r\n\n"); Report("g_ulFreq = %ld \r\n\n",g_ulFreq); i = 0; if(g_ulFreq >= 10){ for(j = 0; j < g_ulFreq ;j++){ Report("timeout iii: %4d %03ld %03ld ",i++ ,g_ulSamples[j] , g_ulSamples[j+1]); Report("Width: %03dms \r\n ",(g_ulSamples[j] - g_ulSamples[j+1])/800); } g_ulFreq = 0; Report("\r\n\n\n\n "); } timeStatus = 1; MAP_TimerEnable(TIMERA3_BASE, TIMER_A); MAP_TimerDisable(TIMERA3_BASE, TIMER_B); } int main() { BoardInit(); PinMuxConfig(); InitTerm(); DisplayBanner(APP_NAME); MAP_TimerIntRegister(TIMERA3_BASE,TIMER_A,TimerIntHandler);//REG CAP MAP_TimerIntRegister(TIMERA3_BASE,TIMER_B,TimerIntHandler_TIME_OUT);//REG TIME_OUT MAP_TimerIntEnable(TIMERA3_BASE,TIMER_CAPA_EVENT);//ALLOW CAP MAP_TimerIntEnable(TIMERA3_BASE,TIMER_TIMB_TIMEOUT);//ALLOW TIME_OUT MAP_TimerConfigure(TIMERA3_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP | TIMER_CFG_B_PERIODIC); // CONGIG A CAP | B PERIODIC MAP_TimerPrescaleSet(TIMERA3_BASE, TIMER_BOTH, 199);//80000000 / 200 = 40 0000 hz = 400khz //PRESCALE 200 MAP_TimerControlEvent(TIMERA3_BASE, TIMER_A, TIMER_EVENT_BOTH_EDGES); MAP_TimerLoadSet(TIMERA3_BASE, TIMER_BOTH, 60000);//150ms MAP_TimerEnable(TIMERA3_BASE,TIMER_A); while(1) { } }
请参考http://www.deyisupport.com/question_answer/wireless_connectivity/wifi/f/105/p/108965/297660.aspx#297660
PIN_50也是普通的IO,和PIN_06没差别,你如果用TIMERA3配上PIN_50可以用吗?