Other Parts Discussed in Thread: SYSBIOS, AM3359
Tool/software: TI-RTOS
custom board with AM3352
SYSBIOS 6.46.1.38
XDC tools 3.32.1.22
I am in Main, so nothing should be running except for main.
we have a routine that allows us to wait an accurate amount of time using the timestamp module. we are transitioning a product to the AM3352 and i need to make sure that routine is still accurate. here is the routine:
void waitusec( Uint32 uSDelay )
{
UInt task_restore_key = Task_disable(); /* Disable TASKS so we can't get preempted by a higher TASK. */
U64 usec_delay_in_ticks = 0;
U64 StartTicks = 0;
U64 CurrentTicks = 0;
Types_FreqHz freq;
Types_Timestamp64 BigTicksStamp;
*GPIO2_CLEARDATAOUT = TEST_FIXTURE_OUTPUT;
if( uSDelay != 0 )
{
/* Figure out how many ticks it takes to equal 1uS. */
Timestamp_getFreq(&freq);
usec_delay_in_ticks = (U64)((freq.lo / 1000000U) * uSDelay);
/* We don't have to worry about checking for a roll over. Our max CPU frequency is 1GHz, or 1nS per "tick". A U64
variable is 1.8 x 10 to the 19th power (really f'ing big). It will take over 1500 years for the Timestamp to roll over.
By the way, the Timestamp module gets it info from core AM3352 registers (TSCH and TSCL). No timers are used. */
Timestamp_get64(&BigTicksStamp);
StartTicks = BigTicksStamp.hi;
StartTicks = StartTicks << 32U;
StartTicks = StartTicks | BigTicksStamp.lo;
while( CurrentTicks < (StartTicks + usec_delay_in_ticks) )
{
/* Do nothing while we wait for the delay to expire. */
Timestamp_get64(&BigTicksStamp);
CurrentTicks = BigTicksStamp.hi;
CurrentTicks = CurrentTicks << 32U;
CurrentTicks = CurrentTicks | BigTicksStamp.lo;
}
}
*GPIO2_SETDATAOUT = TEST_FIXTURE_OUTPUT;
Task_restore(task_restore_key); /* Restore TASK's to their previous state. */
}
the GPIO in/out is for debugging purposes to be able to time the routine on a scope
what i am finding is that this routine is taking 2-3 times the amount of time expected. when i wait 1us i get 3us, when i wait 10us i get 20us.
why would this not be accurate? is there some clock thing that needs to be enabled for this to get the ticks properly?