Tool/software: TI-RTOS
Hi:
I am trying to use the GPTimer , but there are a problem.
I need change the match value of GPTimer in the interrupt function,the pin of GPTimer can output the PWM signal, but the interrupt funtion seems do not work.
here is my code:
PIN_Handle pwmPinHandle;
PIN_State pwmPinState;
PIN_Config pwmPinTable[] = {
Board_DIO1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};
void timerCallbackA(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
{
uint32_t status = TimerIntStatus(GPT0_BASE, true);
if(TIMER_TIMA_TIMEOUT & status)
{
TimerIntClear(GPT0_BASE, TIMER_TIMA_TIMEOUT);
}
PIN_setOutputValue(pwmPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
}
GPTimerCC26XX_Handle hTimer;
GPTimerCC26XX_Params params;
GPTimerCC26XX_Params_init(¶ms);
params.width = GPT_CONFIG_16BIT;
params.mode = GPT_MODE_PWM;//GPT_MODE_PERIODIC_UP;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms);
BIOS_getCpuFreq(&freq);
GPTimerCC26XX_Value loadVal = freq.lo / 50 - 1; //20 ms
GPTimerCC26XX_setLoadValue(hTimer, loadVal);
GPTimerCC26XX_setMatchValue(hTimer, loadVal/4);
pwmPinHandle = PIN_open(&pwmPinState, pwmPinTable);
GPTimerCC26XX_PinMux pinMux = GPTimerCC26XX_getPinMux(hTimer);
PINCC26XX_setMux(pwmPinHandle, Board_DIO1, pinMux);
GPTimerCC26XX_registerInterrupt(hTimer, timerCallbackA, GPT_INT_TIMEOUT);
GPTimerCC26XX_enableInterrupt(hTimer, GPT_INT_TIMEOUT);
GPTimerCC26XX_start(hTimer);
while(1)
{
Task_sleep(BIOS_WAIT_FOREVER);
}
Thanks!