"mbed assertion failure"; what is and how to fix ??

14 Jul 2018

Have come across a runtime error that's new to me and could use a pointer or two. The following bit of code compiles but throws an error at runtime. The serial debug kicks out :

mbed assertation failed: !are_interrupts_enabled(), file: /home/jenkins/mbed_jenkins/workspace/bm_wrlUY1701/mbed-os/hal/mbed_cr6

If I comment out disable/enable_irq there is no error. Can anyone shed a little light for me?

void doDCC()
{
    __disable_irq();
    Control.printf("<t 1 %d %d %d>", LocoAddress[ActiveAddress], LocoSpeed[ActiveAddress], LocoDirection[ActiveAddress]);
    __enable_irq();
}


void setup()
{
    LCD.setCursor(3,2);
    LCD.printf("DCC++ Controller 0.1");
    Control.printf("<0>");
    dcc_clk.attach(doDCC, dccTimer/1000);
    tone2();
}


int main()
{

    t_out.init();

    spi.format(8,3);
    spi.frequency(2000000);

    pc.baud(115200);
    Control.baud(9600);

    channelA_.mode(PullUp);
    channelB_.mode(PullUp);

    chanA = channelA_.read();
    chanB = channelB_.read();

    currState_ = (chanA << 1) | (chanB);
    prevState_ = currState_;

    channelA_.rise(&encode);
    channelA_.fall(&encode);
    channelB_.rise(&encode);
    channelB_.fall(&encode);

    setup();

//...

}

Please log in to post a reply.