Part Number: CC2640R2F
I'm using library <ti/drivers/timer/GPTimerCC26XX.h>
I do not understand the loadvalue variable.
It is supposed to change the value of the register GPT_O_TAILR but when I put 0x00000001, the value I see is 10 ms but if I put 0x0000FFFF, the value es 1 ms
The frequency is 48 MHz, so I understand that 1 tick is 1/48MHz if I am in a periodic timer with count up.
Can anyone explain me what am i doing wrong? or What value corresponds to each tick?
My program is:
void timerCallbackFunction(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask){
// // Begin read
GPIO_toggle(Board_GPIO_LED1);
}
void *mainThread(void *arg0)
{
unsigned int status;
GPTimerCC26XX_Params_init(¶ms);
params.width = GPT_CONFIG_32BIT;
params.mode = GPT_MODE_PERIODIC_UP;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
hTimer = GPTimerCC26XX_open(Board_GPTIMER1A, ¶ms);
loadVal = 0x000000001;
GPTimerCC26XX_setLoadValue(hTimer, loadVal);
GPTimerCC26XX_registerInterrupt(hTimer, timerCallbackFunction, GPT_INT_TIMEOUT);
GPTimerCC26XX_start(hTimer);
/* Call driver init functions */
GPIO_init();
/* Loop forever echoing */
while (1) {
// // Begin read
GPIO_toggle(Board_GPIO_LED0);
sleep(1);
}
}
/* FROM LIBRARY GPTimerCC26XX*/
static void GPTimerCC26XXSetLoadMatch(GPTimerCC26XX_Handle handle, GPTimerCC26XX_Value loadMatchVal, uint32_t regPre, uint32_t regLoadMatch)
{
/* Get the pointer to the object and hwAttrs */
GPTimerCC26XX_HWAttrs const *hwAttrs = handle->hwAttrs;
GPTimerCC26XX_Object *object = handle->object;
uint32_t offset = GPT_LUT[handle->timerPart].offset;
/* Split value into correct timer and prescaler register for 16 bit modes. */
if (object->width == GPT_CONFIG_16BIT)
{
/* Upper byte is used by prescaler */
uint8_t prescaleValue = 0xFF & (loadMatchVal >> 16);
/* Discard upper byte (24 bits max) */
loadMatchVal &= 0xFFFF;
/* Set prescale value */
HWREG(hwAttrs->baseAddr + offset + regPre) = prescaleValue;
}
/* Set load / match value */
HWREG(hwAttrs->baseAddr + offset + regLoadMatch) = loadMatchVal;
}
void GPTimerCC26XX_setLoadValue(GPTimerCC26XX_Handle handle, GPTimerCC26XX_Value loadValue)
{
GPTimerCC26XXSetLoadMatch(handle, loadValue, GPT_O_TAPR, GPT_O_TAILR);
}