GPTimerCC26XX_Params params;
GPTimerCC26XX_Params_init(¶ms);
params.width = GPT_CONFIG_16BIT;
//params.mode = GPT_MODE_PERIODIC;
params.mode = GPT_MODE_EDGE_COUNT;
params.direction = GPTimerCC26XX_DIRECTION_UP;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
hTimer = GPTimerCC26XX_open(Board_GPTIMER0B, ¶ms);
if(hTimer == NULL) {
Log_error0("Failed to open GPTimer");
}else{
Log_info0("SUCESS to open GPTimer");
}
// Register interrupt when capture happens
// GPT_MODE_EDGE_COUNT seems to trigger GPT_INT_CAPTURE_MATCH interrupts
GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_CAPTURE_MATCH);
// Open pin handle and route pin to timer
timerPinHandle = PIN_open(&timerPinState, gptPinInitTable);
GPTimerCC26XX_PinMux pinMux = GPTimerCC26XX_getPinMux(hTimer);
PINCC26XX_setMux(timerPinHandle, PIN_ID(Board_ENCODER), pinMux);
GPTimerCC26XX_setCaptureEdge(hTimer, GPTimerCC26XX_BOTH_EDGES);
// When counting in upwads direction LoadValue needs to be at least as
// large as matchValue for interrupts to work.
GPTimerCC26XX_setLoadValue(hTimer, 0xFFFF);
GPTimerCC26XX_setMatchValue(hTimer, 65535);
GPTimerCC26XX_start(hTimer);
// When counting in upwads direction LoadValue needs to be at least as
// large as matchValue for interrupts to work.
GPTimerCC26XX_setLoadValue(hTimer, 0xFFFF);
GPTimerCC26XX_setMatchValue(hTimer, 65535);
GPTimerCC26XX_setLoadValue(hTimer, 0xFFFF);函数都会触发回调函数吗?我设置的是 GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_CAPTURE_MATCH);触发回调函数而还在每次调用之后清除计数值,为啥会打印出0,不是要65535才触发回调函数吗?
Lease:
GPTimerCC26XX_setLoadValue(hTimer, 0xFFFF);这函数设置的数值对GPT_INT_CAPTURE_MATCH有啥影响
Lease:
回复 Kevin Qiu1:
我还是有点不理解,能麻烦你解释一下以下的情况吗?
1,params.mode= GPT_MODE_EDGE_COUNT; 设置的是边缘记数模式。
GPTimerCC26XX_setCaptureEdge(hTimer, GPTimerCC26XX_BOTH_EDGES);
我猜想的是捕捉我输入源方波信号的上升沿个数达到我GPTimerCC26XX_setMatchValue()设置参数值的时触发中断,
而GPTimerCC26XX_setLoadValue()是GPTimer定时器48mhz所需要计数时间?
Lease:
回复 Lease:
如果当GPTimerCC26XX_setLoadValue()和GPTimerCC26XX_setMatchValue()参数值相等时就会触发中断。那请问一下我GPTimerCC26XX_setCaptureEdge(hTimer, GPTimerCC26XX_BOTH_EDGES)捕捉到的边缘个数存放在哪个寄存器中,我所读的寄存器是TBV,不是TBR寄存器。
TBV寄存器存放的值是哪个值,是GPTimerTi系统脉冲的计数值,还是我捕捉的输入源脉冲边缘的计数值。那TBR寄存器存放的又是什么值?
Lease:
回复 Kevin Qiu1:
在ti的文件,并没有看到详细的解释和说明
Lease:
回复 Lease:
Lease:
回复 Kevin Qiu1:
Kevin Qiu1:
回复 Lease:
关于寄存器你可以看下手册13.5节,TBV的值会在下一个时钟周期载入TBR寄存器