Tool/software: TI-RTOS
Hi,
I need a 32 bit up-count timer to use for my application in my SensorTag device (cc2650). I have spent a lot of time on this and still I am confused.
First of all I used this timer:
#include <ti/sysbios/hal/Timer.h>
Error_Block eb;
Timer_Params timer_Params;
Error_init(&eb);
Timer_Params_init(&timer_Params);
timer_Params.period = 60000;
timer_Params.periodType = Timer_PeriodType_MICROSECS;
timer_Params.arg = 2 ;
timer_Params.extFreq.lo = 270000000;
timer_Params.extFreq.hi = 0;
timer_Params.startMode = Timer_StartMode_AUTO;
timer_Params.runMode = Timer_RunMode_CONTINUOUS;
timer_Handle = Timer_create(0, tickFxn, &timer_Params, &eb);
if (timer_Handle == NULL) {
System_abort("Timer create failed!");
}
I could get the timer value right but the timer is descending.
So I used the GPTM instead:
#include <ti/drivers/timer/GPTimerCC26XX.h>
GPTimerCC26XX_Params params;
GPTimerCC26XX_Params_init(¶ms);
params.width = GPT_CONFIG_32BIT;
params.mode = GPT_MODE_PERIODIC_UP;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
hTimer = GPTimerCC26XX_open(CC2650_GPTIMER0A, ¶ms);
if(hTimer == NULL) {
Log_error0("Failed to open GPTimer");
}
Types_FreqHz freq;
BIOS_getCpuFreq(&freq);
GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999
GPTimerCC26XX_setLoadValue(hTimer, loadVal);
// GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT);
GPTimerCC26XX_start(hTimer);
Prescaling did not work for me so I could not get the 1 micro second precision.
Then I tried to use this timer:
PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
Power_setDependency(PowerCC26XX_PERIPH_GPT0);
Power_setConstraint(PowerCC26XX_SB_DISALLOW );
PRCMLoadSet();
Power_setDependency(PRCM_PERIPH_TIMER0);
PRCMLoadSet();
TimerDisable(GPT0_BASE, TIMER_BOTH ); //to make sure that the GPTM is disabled
//TimerCcpCombineDisable(GPT0_BASE ); //disables A and B to be used together
TimerConfigure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR |TIMER_CFG_PERIODIC);
TimerPrescaleSet(GPT0_BASE, TIMER_BOTH, 16);
TimerLoadSet(GPT0_BASE, TIMER_BOTH, 0xFFFFFFFF ); //load timer value to count
TimerEnable(GPT0_BASE, TIMER_BOTH );
In this Timer also, the Prescailer did not work. I read that it work for 16 bit but I need 32 bit timer with ascending value.
I appreciate your answer.
Regards,
BenBad