Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hi there,
I´m trying to build a clock function to do two thing: establish 10 second periods (my tasks will sleep for this amount after being executed) and create a a date and real clock (hours, minutes, seconds and milissenconds). I'm tryin this with Clock_getTicks() to generate the 10 second period counter. The problem after 1hour and 11 minutes it overflows and the clock doesn't work anymore. Can anyone help me to handle this overflow? My clock piece of code is
uint32_t adcMean, absTime, absTimeOld,absPeriod, absPeriodSec;
unsigned int period = 10;
void clkFxn(void) {
static unsigned int firstTime = 0;
absTimeOld = absTime;
absTime = Clock_getTicks()*Clock_tickPeriod/1000;
absPeriod = absTime - absTimeOld;
if(absTime < absTimeOld) {
absTime = 0;
absTimeOld = 0;
absPeriod = 10000;
}
absPeriodSec = absPeriod/(period*100);
if(absPeriodSec < period) {
relogio.msec = relogio.msec + (absPeriod - (period-1)*1000);
}
else {
relogio.msec = relogio.msec + (absPeriod - period*1000);
}
after that just normal conversions from msec to sec, sec to min and so forth.
Thank you!