Tx2 SPI is not stable

Hi

Now I’m using Tx2. And try to send data through SPI communication.

// Receive Data From SPI
	for(int loop = 0 ; loop < TESTLOOP; loop++)
	{
	
		iStart = cpuTimer();	// Check Time	
		ioctl(fd, SPI_IOC_MESSAGE(1), &tr);	// Send Data 

	}
	printf("Average elapsed time on CPU : %f\n",ElapsedTimeOnCPU/TESTLOOP);	// Print Time
	close(fd);

but the Time always different. 0.004 s , 0.002 s …

My test environment is short with SI SO (Loop back test)

Am I missing some code or need other HW ?

Thanks

The SPI message is schedule by kernel scheduling process.
Could you run the jetson_clocks.sh to check if any improve.

The timer you are using may not be precise enough for below 10 milliseconds. You can use the timer out of loop and calculate average value to have a more stable timing.