Part Number:TMS320C6657
高32位在前 低三十二位在后 第二个351按理论应进位为352
读count值的操作如下
进位产生的突变
Shine:
请问定时器使用的是什么mode?
,
user6372605:
,
user6372605:
,
user6372605:
我单独使用64bit timer没有问题,,工程里面和32bit timer一起使用 进位问题就出现了
,
Shine:
请详细描述一下您的timer配置,如64bit timer时用到了哪个timer,配置成了什么mode? 32bit timer时用到了哪个timer,配置成了什么mode? 单独的32bit timer可以正常运行吗?
,
user6372605:
32bit单独使用正常 具体不知道您说的是模式指什么 下面我将把所欲关于两个定时器的操作以贴图放上来
64bit 配置是timer_test.c 中包含的test_gp_timer 用的是TIMR0 配置如下
Int32 test_gp_timer (Uint8 IntcInstance){
/* Clear local data structures */ memset(&TmrObj, 0, sizeof(CSL_TmrObj));// printf("Debug: Testing 64bit Timer in Single Shot Mode…\n");
/************************************************************** ********************** INTC related code ********************* **************************************************************/
/* Open INTC */ vectId = CSL_INTC_VECTID_12; tmrIntcHandle = CSL_intcOpen(&tmrIntcObj, CSL_GEM_TINTLN, &vectId, NULL);
/* Bind ISR to Interrupt */ EventRecord.handler = (CSL_IntcEventHandler)&TimerInterruptHandler0; EventRecord.arg = (void *)CSL_GEM_TINTLN; CSL_intcPlugEventHandler(tmrIntcHandle, &EventRecord);
/* Event Enable */ CSL_intcHwControl(tmrIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);
/************************************************************** ********************** Timer related code ******************** **************************************************************/
/* Open the timer. */ hTmr = CSL_tmrOpen(&TmrObj, IntcInstance, NULL, &status); if (hTmr == NULL) return -1;
/* Set the timer mode to 64bit GP Timer Mode and set the PRD registers */ hwSetup.tmrTimerMode = CSL_TMR_TIMMODE_GPT; hwSetup.tmrTimerPeriodLo = 0xFFFFFFFF; //16998406000 hwSetup.tmrTimerPeriodHi = 0xF0000003; CSL_tmrHwSetup(hTmr, &hwSetup);
/* Reset the timer ISR Counter. */ timerISRCounter0 = 0;
/* Reset the Timer */ CSL_tmrHwControl(hTmr, CSL_TMR_CMD_RESET64, NULL);
/* Start the timer in SINGLE SHOT Mode. */ CSL_tmrHwControl(hTmr, CSL_TMR_CMD_START64, (void *)&TimeCountMode);
return 0;
}
32bit用的是TIMER2 默认配置的来 具体如下
Int32 test_32bit_timer (Uint32 *LoadValue) { /************************************************************** ********************** 初始化Timer1 ********************* **************************************************************/ /* Clear local data structures */ memset(&TmrObj1, 0, sizeof(CSL_TmrObj)); /************************************************************** ********************** INTC related code ********************* **************************************************************/ /* Open INTC */ vectId1 = CSL_INTC_VECTID_5; tmrIntcHandle1 = CSL_intcOpen(&tmrIntcObj1, CSL_GEM_TINT2L, &vectId1, NULL);
/* Bind ISR to Interrupt */ EventRecord1.handler = (CSL_IntcEventHandler)&TimerInterruptHandler1; EventRecord1.arg = (void *)CSL_GEM_TINT2L; CSL_intcPlugEventHandler(tmrIntcHandle1, &EventRecord1);
/* Event Enable */ CSL_intcHwControl(tmrIntcHandle1, CSL_INTC_CMD_EVTENABLE, NULL); /************************************************************** ********************** Timer related code ******************** **************************************************************/ /* Open the timer. */ hTmr1 = CSL_tmrOpen(&TmrObj1, CSL_TMR_2, NULL, &status1);
/* Open the timer with the defaults. */ CSL_tmrHwSetup(hTmr1, &hwSetup1);
/* Stop the Timer */ CSL_tmrHwControl(hTmr1, CSL_TMR_CMD_RESET_TIMLO, NULL);
/* Set the timer mode to unchained dual mode */ hwSetup1.tmrTimerMode = CSL_TMR_TIMMODE_DUAL_UNCHAINED; CSL_tmrHwSetup(hTmr1, &hwSetup1);
/* Reset the timer ISR Counter. */ timerISRCounter1 = 0;
/* Load the period register */ status1 = CSL_tmrHwControl(hTmr1, CSL_TMR_CMD_LOAD_PRDLO, (void *)LoadValue);
CSL_tmrHwControl(hTmr1, CSL_TMR_CMD_START_TIMLO, (void *)&TimeCountMode1);
return 0; }
,
Shine:
尝试一下一个timer用中断,一个timer用轮询方式,看是不是中断之间互相影响?