Tool/software: TI-RTOS
In my test Ti-RTOS application, only one 24MHz DMtimer3 is enabled, the period is 0.1ms,.
The timer interrupt service record the timestamp every 10 times, the record timestamp and the last one to calculate the difference.
The delta timestamp is analyzed, and it is found that the timed interrupt service fails to respond, there are three responses are loss.
hwi interrupt service function:
void CClockTick::isr()
{
static int i = 0;
if(++i % 10 == 0)
{
UINT32 key;
key = Hwi_disable();
UINT32 timestamp = TimestampProvider_get32();
static UINT32 s_timestamp = timestamp;
g_timestampClock = timestamp - s_timestamp;
s_timestamp = timestamp;
g_timestampDelta = TimestampProvider_get32() - timestamp;
Hwi_restore(key);
Clock_tick();
CSysManager::GetInstance().m_SemSample.post();
}
}
the task function , echo the timestamp:
void CSampleTask::run()
{
while(1)
{
(CSysManager::GetInstance()).m_SemSample.pend();
int delta = 0;
delta = g_timestampClock - 300000;
static UINT32 deltaMax = 0;
if(abs(delta) > deltaMax)
deltaMax = abs(delta);
UART_printf("g_timestampClock: %u delta=%d maxdelta=%u\n",g_timestampClock,delta,deltaMax);
}
}
301869 / 300000000 = 0.001s = 1ms ; 90116/300 = 300us = 0.3ms ( cpufreq=300000000) loss three responses. why?
display one log every millisecond, some snapshot as below :
g_timestampClock: 301869 delta=1869 maxdelta=90116
g_timestampClock: 300131 delta=131 maxdelta=90116
g_timestampClock: 300403 delta=403 maxdelta=90116
g_timestampClock: 302948 delta=2948 maxdelta=90116
g_timestampClock: 300164 delta=164 maxdelta=90116
g_timestampClock: 300164 delta=164 maxdelta=90116
g_timestampClock: 300891 delta=891 maxdelta=90116
g_timestampClock: 300138 delta=138 maxdelta=90116