SPE-fw is getting error with <time.h> undefined reference to `_times'

Hi all,

I tried to learn for SPE-fw number of clock ticks elapsed since the program was launched.To get the number of seconds used by the CPU.

How could I get like this output of trigger real time system(FreeRTOS for Tx2).

I can use <time.h> in host pc with gcc but not work in SPE-fw.
output of following my host pc:

0.791106 sec 
0.791109 sec 
0.791111 sec 
0.791113 sec 
0.791115 sec

But Im getting following error in tx2 SPE-fw

timesr.c:(.text._times_r+0x2): undefined reference to `_times'

in my spe-fw code. How could I fix it or which library can I use?

#include<time.h>
...
...
...
        char newLine[2] = " \n";
        int  newLineLength = sizeof(newLine) - 1; 

        char output[12];
	int outputLength; 

	char tx_message[] = "LED OFF : ";    	
	int tx_len = sizeof(tx_message) - 1;

	char tx_message2[] = "LED ON - ";    	
	int tx_len2 = sizeof(tx_message2) - 1;

	start = clock();
	double time_taken = 0.0; 
	
        while (1) {
		printf("%s - Setting GPIO_APP_OUT to 1 - IRQ should trigger\r\n",
		       __func__);
        
		gpio_set_value(GPIO_APP_OUT, 1);		
		vTaskDelay(GPIO_OUT_SET_DELAY);
	        end = clock();				        
                time_taken = (double)(end - start) / CLOCKS_PER_SEC;
		tegra_uart_write_now(&UART_APP_PORT, tx_message, tx_len);
		snprintf(output, 12, "%f", time_taken);
	        outputLength = sizeof(output) - 1; 
		tegra_uart_write_now(&UART_APP_PORT, output, outputLength);
		tegra_uart_write_now(&UART_APP_PORT, newLine, newLineLength);

		gpio_set_value(GPIO_APP_OUT, 0);		
		vTaskDelay(GPIO_OUT_SET_DELAY);
	        end = clock();
		time_taken = (double)(end - start) / CLOCKS_PER_SEC;		
		tegra_uart_write_now(&UART_APP_PORT, tx_message2, tx_len2);
                snprintf(output, 12, "%f", time_taken);
	        outputLength = sizeof(output) - 1; 
		tegra_uart_write_now(&UART_APP_PORT, output, outputLength);
		tegra_uart_write_now(&UART_APP_PORT, newLine, newLineLength);
	};

Anyone knows?? How can calculate response time in spe-fw?

Hello, hamzaygrtc:
You can call tegra_tke_get_usec() to get timer in micro-seconds. Refer to “rt-aux-cpu-demo/app/timer-app.c” and corresponding codes for details.

br
Chenjian

Hello jachen,

uint32_t usec, osc, tsc_hi, tsc_lo;

there are uint32_t numbers. What are meaning of numbers?

usec = 5236147, osc = 201785430 , tsc_hi = 0, tsc_lo = 161690429

I need taken time like double time like this from the beginning of spe-fw :

0.791106 sec
0.891106 sec
...
...

Hello, hamzaygrtc:
usec is rating at 1MHz, i.e. micro-second.

br
Chenjian