Μάθημα : Ενσωματωμένα Συστήματα

Κωδικός : ECE292

9.012  -  George Kornaros

Ανακοινώσεις

Measuring elapsed time in Zedboard (and FreeRTOS)

Method 1:

by using the Global timer/counter:

   a) https://adaptivesupport.amd.com/s/question/0D52E00006hpU6USAU/time-measurement-in-sdk?language=en_US

   b) https://forums.freertos.org/t/measure-time-within-a-task-with-xtaskgettickcount/7401

 

Method 2:

by using the XScuTimer, such as the following example:

 

static void prvRxTask( void *pvParameters )
{
int message = 0;
int Status;
volatile u32 CntValue2 = 0;
XScuTimer Timer;
XScuTimer_Config *ConfigPtr;

ConfigPtr = XScuTimer_LookupConfig(TIMER_DEVICE_ID);

Status = XScuTimer_CfgInitialize(&Timer, ConfigPtr, ConfigPtr->BaseAddr);
if (Status != XST_SUCCESS) {
print("ERROR\n");
return;
}

XScuTimer_LoadTimer(&Timer, TIMER_LOAD_VALUE);

/* Block to wait for data arriving on the queue. */
xQueueReceive(xQueue, /* The queue being read. */
&message, /* Data is read into this address. */
portMAX_DELAY ); /* Wait without a timeout for data. */

XScuTimer_Start(&Timer);

/* Block to wait for data arriving on the queue. */
xQueueReceive(xQueue, /* The queue being read. */
&message, /* Data is read into this address. */
portMAX_DELAY ); /* Wait without a timeout for data. */

CntValue2 = XScuTimer_GetCounterValue(&Timer);


XScuTimer_Stop(&Timer);
xil_printf("Elapsed: %d ticks\r\n", TIMER_LOAD_VALUE - CntValue2);
printf("Elapsed: %f micro seconds\r\n", (TIMER_LOAD_VALUE - CntValue2)/(float)333);
}