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.

Linux/AM3358: Timer example issue

Part Number: AM3358

Tool/software: Linux

Hi,

we find an issue when we call timer functions in our application, below are the steps we can reproduce it:

SDK: ti-processor-sdk-linux-rt-am335x-evm-04.02.00.09 pre-build images

Hardware: Am335x ICE Board Rev 2.1A

1, copy a timer example code timer.c to board

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <string.h>

void timerCallback(union sigval sig_value)
{
	void *pData = sig_value.sival_ptr;
	printf("Pointer = %p\n", pData);
	fflush(stdout);
}

/*
 * 
 */
int main(int argc, char** argv) {
	timer_t timerid = 0;
	struct sigevent sigevent;
	struct itimerspec timerspec;
	int err = 0;
	memset(&sigevent, 0, sizeof(sigevent));
	memset(&timerspec, 0, sizeof(timerspec));
	
	sigevent.sigev_notify = SIGEV_THREAD;
	sigevent.sigev_notify_function = timerCallback;
	sigevent.sigev_value.sival_ptr = (void*) 0x1234;
	
	err = timer_create(CLOCK_MONOTONIC, &sigevent, &timerid);
	if(err != 0)
	{
		perror("Timer create failed");
		return EXIT_FAILURE;
	}
	
	timerspec.it_value.tv_sec = 2;
	timerspec.it_interval.tv_sec = 2;
	err = timer_settime(timerid, 0, &timerspec, NULL);
	if(err != 0)
	{
		perror("Timer settime failed");
		return EXIT_FAILURE;
	}
	
	for(;;)
	{
		sleep(10);
	}
	
	
	return EXIT_SUCCESS;
}

2, compiled it in board:

gcc timer.c -o timertest -lrt

3, run the application:

root@am335x-evm:~# ./timertest
Pointer = 0x1234

the application only output "Pointer = 0x1234" once.

4, I test this code in my ubuntu host and it keeps printing "Pointer = 0x1234" every 2 seconds.

VirtualBox:~/tmp$ ./timertest
Pointer = 0x1234
Pointer = 0x1234
Pointer = 0x1234
Pointer = 0x1234
^C

I am not sure if it is related to driver or any application library.
could anybody give me any advice?

Best regards

Dylan