Other Parts Discussed in Thread: SYSBIOS
Tool/software: Code Composer Studio
Hi,
We are trying to implement pulse counter for rotary encoder with GPTimerCC26XX.h.
timerCallback is working, when we use timerParams.mode = GPT_MODE_EDGE_TIME, but not with GPT_MODE_EDGE_COUNT.
Could anyone explain why it does not work?
void timerCallback(GPTimerCC26XX_Handle handle,
GPTimerCC26XX_IntMask interruptMask) {
Log_info0("interrupt");
}
PIN_Config GptPinInitTable[] = {
PIN_ID(Board_ENCODER) | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
PIN_TERMINATE
};
static void ProjectZero_init(void)
{
...
GPTimerCC26XX_Params timerParams;
GPTimerCC26XX_Handle hTimer;
GPTimerCC26XX_Params_init(&timerParams);
timerParams.mode = GPT_MODE_EDGE_COUNT;
timerParams.width = GPT_CONFIG_16BIT;
hTimer = GPTimerCC26XX_open(CC2640R2_LAUNCHXL_GPTIMER0A, &timerParams);
// Register interrupt when capture happens
GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_CAPTURE);
// 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);
GPTimerCC26XX_setLoadValue(hTimer, 0x0000);
GPTimerCC26XX_setMatchValue(hTimer, 0x0010);
GPTimerCC26XX_start(hTimer);
}