[riot-devel] rtc alarm running with threads

Paula Ortega Cancino pportega at uc.cl
Fri Oct 20 21:45:08 CEST 2017


Hi Oleg,

Thanks for your help. I should mention that i'm working on the 2017.07
release. This is the main functions of the code, the behavor i'm expecting
is to trigger the alarm every TIME_WAITING seconds, run sale_test() and the
go back to the control thread. However i get a kernel panic or run only the
control_thread, without considering the rtc_alarm after a while.

char stack[THREAD_STACKSIZE_DEFAULT];
kernel_pid_t control_pid;

int sale_test(void){
    DEBUG("Send sale\n");
    return 1;
}

/* set interrupt event every TIME_WAITING  = 10 seconds*/
static void onInterruptEvent(void *arg)
{
    (void)arg;
    struct tm time;
    rtc_get_alarm(&time);

    /* schedule next message */
    time.tm_sec  += TIME_WAITING;
    /* Make an interrupt */
    sale_test();

    rtc_clear_alarm();
    rtc_set_alarm(&time, onInterruptEvent, 0);
}

void *control_thread(void *arg)
{
    (void) arg;
    while (1) {
      DEBUG("Running thread right now\n");
      xtimer_usleep(100000);
    }
    return NULL;
}

int main(void)
{
    printf("This test will display 'Alarm every %i seconds'\n",
TIME_WAITING);

    /* initialize rtc functions */
    application_init();

    onInterruptEvent(NULL);

    control_pid = thread_create(stack, sizeof(stack),
    THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST,
    control_thread, NULL, "control");
    (void) control_pid;

    return 0;
}

Cheers,
Paula

2017-10-19 14:41 GMT-03:00 Oleg Hahm <oleg at riot-os.org>:

> Dear Paula,
>
> can you share the code of your application somewhere? That might help to
> find
> the issues. I would suppose that the interrupt handler is faulty or
> consumes
> too much memory or something like this.
>
> I think start debugging with a basic application that just prints some text
> whenever a message from the RTC interrupt is received is a smart idea.
> Now, we
> need to figure out what exactly triggers the kernel panic. Are you
> compiling
> your application with the DEVELHELP macro enabled? And which port are you
> using? Maybe you can use `make debug` to get more information.
>
> Cheers,
> Oleg
> --
> /* Fuck, we are miserable poor guys... */
>         linux-2.6.6/net/xfrm/xfrm_algo.c
>
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20171020/482bab27/attachment.html>


More information about the devel mailing list