This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/PROCESSOR-SDK-AM437X: 1ms Timer issue

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?

  • Hi Chris,

    Do you use AM437x PSDK RTOS v6.00?

    You need to check which AM437x timer exactly (DMTimer 1ms or other) you are using. Then you need to verify that you supply the correct clock source to that timer. For more info you can refer to AM437x TRM, chapter 19 Timers

    Regards,
    Pavel

  • I am using:

    CCS Version: 8.3.1.00004
    SYS/BIOS 6.73.1.01

    AM437x PDK 1.0.13
    XDCtools 3.50.8.24

    I thought there was already a 1ms DMTimer set up?

  • Chris,

    You can dump DMTIMER1_1MS (base addr 0x44E31000) registers to check if this is the timer being used by your application. You can also refer the timer diagnostic test, this test verifies the on-chip timer module to generate 1msec tick on the HW platform under test. Test waits for 2secs counting the timer interrupt.

    pdk_am437x_x/packages/ti/board/diag/timer/src/timer_test.h

    Check also below pointers regarding timer usage:

    Regards,
    Pavel