Search code examples
ctimerembeddedsensorscontiki

Contiki clock time module does not update


I am trying to generate some samples periodically in Contiki. I use ctimer to generate it, as shown below:

PROCESS_THREAD(null_app_process, ev, data)
{
    PROCESS_BEGIN();
    printf("Sine Wave Started\n");

    app_conn_open(&nullApp_callback);

    if (node_id != 0)
    {
        ctimer_set(&ct,102,sample_fun,(void*)NULL);
    }
    PROCESS_END();
}

static void sample_fun(void)
{
    int8_t data_buf[6] = {0};
    uint8_t i;
    for(i = 0; i < 6; i++)
    {
        data_buf[i] = sinI(counter);
        counter++;
    }
    app_conn_send((uint8_t *)data_buf,6*sizeof(int8_t));
    ctimer_reset(&ct);

}

However, the samples are not generated periodically, as seen from the log below:

TDMA RDC: SN sends 52, 12 bytes 14202
0,165,16,
TDMA RDC: SN sends 53, 18 bytes 14458
0,166,16,
TDMA RDC: SN sends 54, 12 bytes 14714
0,167,16,
TDMA RDC: SN sends 55, 18 bytes 14970
0,168,16,
TDMA RDC: SN sends 56, 12 bytes 15226
0,169,16,
TDMA RDC: SN sends 57, 18 bytes 15482
0,170,16,
TDMA RDC: SN sends 58, 12 bytes 15738
0,171,16,
TDMA RDC: SN sends 59, 18 bytes 15994
0,172,16,
TDMA RDC: SN sends 60, 12 bytes 16250
0,173,16,
TDMA RDC: SN sends 61, 0 bytes 16257
0,174,16,
TDMA RDC: SN sends 62, 0 bytes 16257
0,175,16,
TDMA RDC: SN sends 63, 0 bytes 16257
0,176,16,
TDMA RDC: SN sends 64, 0 bytes 16257
0,177,16,
TDMA RDC: SN sends 65, 0 bytes 16257
0,178,16,
TDMA RDC: SN sends 66, 0 bytes 16257
0,179,16,
TDMA RDC: SN sends 67, 0 bytes 16257
0,180,16,
TDMA RDC: SN sends 68, 0 bytes 16257
0,181,16,
TDMA RDC: SN sends 69, 18 bytes 16506
0,182,16,
TDMA RDC: SN sends 70, 12 bytes 16762
0,183,16,
TDMA RDC: SN sends 71, 18 bytes 17018
0,184,16,
TDMA RDC: SN sends 72, 12 bytes 17274
0,185,16,
TDMA RDC: SN sends 73, 18 bytes 17530

When the samples are generated, SN sends several bytes. When the sample is not generated, SN sends zero bytes. The number at the end of the line is the clock time (clock_time()). It looks like that the clock time is not updated when no samples are generated. Therefore, I suspect that the clock module does not update at some situation. Does any one have seen this before? If so, could explain the reason?


Solution

  • I am using Sky mote. The suggestion given @kfx fixes the issue. In my code, the frozen period is exactly 2 seconds (I am using 1024 ticks as one second and the transmission period is 1/4 second). The patch given by @kfx ( github.com/contiki-os/contiki/pull/727) fixes this problem which is due to the incorrect module of MSP430 f1xxx.