pkarashchenko commented on pull request #5424:
URL: https://github.com/apache/incubator-nuttx/pull/5424#issuecomment-1030880794
> It's just because you start the POSIX timer at the same time of schedule
timer interrupt(10*n in above example).
It does not matter when I'm starting a timer. This change is not about timer
start, but about timer reschedule that is done in SYS Tick ISR handler, so it
is always in sync with timer interrupt.
> You can try to start your POSIX timer in a GPIO interrupt handler, toggle
the GPIO by hand, and measure the result. In most case, you will see what I
describe here, because GPIO can happen randomly in one tick
period(0ms-9.9999ms).
I will try, but I can ensure you that it will be the same. But I will make a
test with real HW and send you a picture from the logic analyzer.
BTW my programs look like:
```
int periodic_main(int argc, char *argv[])
{
int ret;
timer_t timerid;
struct itimerspec time_value;
struct sigevent ev;
struct siginfo value;
sigset_t set;
ret = timer_create(CLOCK_REALTIME, &ev, &timerid);
if (ret < 0)
{
syslog(LOG_ALERT, "ERROR: timer_create() failed: %d\n", errno);
return EXIT_FAILURE;
}
/* Ignore the default signal action */
signal(SIGALRM, SIG_IGN);
/* Set up a signal to wake-up periodically */
time_value.it_value.tv_sec = 0;
time_value.it_value.tv_nsec = 30000000;
time_value.it_interval.tv_sec = 0;
time_value.it_interval.tv_nsec = 30000000;
ret = timer_settime(timerid, 0, &time_value, NULL);
if (ret < 0)
{
syslog(LOG_ALERT, "ERROR: timer_settime() failed: %d\n", errno);
return EXIT_FAILURE;
}
for (; ; )
{
/* Wait for a signal */
sigemptyset(&set);
sigaddset(&set, SIGALRM);
ret = sigwaitinfo(&set, &value);
if (ret < 0)
{
}
else
{
/* Perform periodic action here */
}
}
return 0;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]