Part Number: PROCESSOR-SDK-AM437X
Tool/software: Code Composer Studio
I have set up a 1ms timer on my AM437x IDK, but it does not seem to be working correctly. I have a print statement that is supposed to print out every 5 seconds, but instead it is am printing every 5.9 seconds.
I have my Initialization as follows:
void Clock::Initialize()
{
Timer_Params timerParams;
Timer_Params_init(&timerParams);
timerParams.period = 1000; /* 1 ms */
Timer_create(Timer_ANY, timerISR, &timerParams, NULL);
}
// This function runs every 1 ms and should run in the ISR context from one of the on board timers
void timerISR(UArg arg0)
{
Clock::Tick(CLOCK_MS);
}
volatile uint32_t Clock::m_milliseconds = 0; volatile uint32_t Clock::m_seconds = 0;
void Clock::Tick(Clock_Units units /* = CLOCK_MS */)
{
switch(units)
{
case CLOCK_MS:
if (++m_milliseconds >= 1000)
{
m_seconds++;
m_milliseconds = 0;
}
break;
case CLOCK_S:
m_seconds++;
m_milliseconds = 0;
break;
}
}
The above code is pretty simple. timerISR should get called every millisecond like programmed to do in the initialize function. From there, it simply increments a counter. When the counter of ms reaches 1000, the seconds value is incremented and the ms is set back to 0.
However, when I do a simple code call to check if 5000 ms has passed, and to print, I get the following: (This shows that the timer is averaging around 5.93 seconds per call)
Any ideas as to why this occurs?
