PlatformIO Community

Need help with trying to set a Contiki timer -> Core 1 panic'ed (LoadProhibited)

I’m trying to set a timer using the ContikiCoreForArduino library. The reason for using this library is because I’m experimenting with protothreads so I’m including that library already anyway.

According to the documentation it should be fairly straightforward, but when I try to set the timer I’m getting a Core panic.

I’m not new to software development, but I did just start tinkering with embedded development, PlatformIO and cpp so forgive me if I’m missing the obvious here. Platform is espressif32, framework is arduino.

This is my code:

#include <Arduino.h>
#include "contiki.h"

static struct timer t;
static struct pt pt1;

static int protothreadFunction(struct pt *pt)
  static int i = 0;

  while (1)
    PT_WAIT_UNTIL(pt, timer_expired(&t));
    timer_set(&t, 1000);

void setup()
  Serial.println("Program start, setting timer");
  timer_set(&t, 1000);
  Serial.println("Timer set");

void loop()

Which results in this:

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
mode:DIO, clock div:2
entry 0x400806ac
Program start, setting timer
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400e91ef  PS      : 0x00060130  A0      : 0x800d0cc8  A1      : 0x3ffb1f20
A2      : 0x00000000  A3      : 0x3f4012ce  A4      : 0x0000001c  A5      : 0x0000ff00
A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x800d0f3d  A9      : 0x3ffb1f00
A10     : 0x00000002  A11     : 0x3f4012ce  A12     : 0x00000002  A13     : 0x0000ff00
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x0000001f  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff

Backtrace: 0x400e91ef:0x3ffb1f20 0x400d0cc5:0x3ffb1f40 0x400d0c79:0x3ffb1f60 0x400d0c01:0x3ffb1f80 0x400d1e0b:0x3ffb1fb0 0x40088215:0x3ffb1fd0


Any help or suggestions are most appreciated, thanks!

Will call

with clock_time() being

In your case timer is still NULL because you do not call the low-level initialization which will call clock_start().

As seen in this example

You need to call it explicitly.

1 Like

That’s brilliant! Thanks for the solution and the quick response! I had no idea clock_start() was needed explicitly, but makes sense now.