Hello
We are trying to read data from an accelerometer at 128 samples/s by using an event timer in Contiki and noticed that etimer_set(&et, CLOCK_SECOND*N) works fine for N>=1, but for N<1 the timer period is not valid when compared to timestamps obtained from timer.
Verifying in Cooja with the following code also leads into the same problem:
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
while(1)
{
static struct etimer et;
etimer_set(&et,CLOCK_SECOND*(1/2));
int t1;
t1=RTIMER_NOW();
printf("t1 is %d\n",t1);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
printf("Hello, world\n");
}
PROCESS_END();
}
1 *CLOCK_SECOND results in increments by 1000 in t1. However, 1/2 *CLOCK_SECOND results in increments by just 1 in t1 whereas 500 is expected.
This is very confusing. Does this mean event timer cannot be used for events happening faster than once a second? Are we making a mistake in using timers?
Thank you!