This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

mBed's Thread::wait() causes interrupts to stop working

Hi,

We have issues with mBed's Thread::wait() in mBed 5.7.2, which causes our interrupts to stop working. Below is a small example that can be used to test this. By removing Thread::wait(), the code works. It does however work with Thread::wait() for a small time, before it hangs (deadlock?)

#include "mbed.h"

DigitalOut led1(LED1);


#define SIGNAL_EVENT_TIMEOUT        0x0200

static osThreadId  sThreadId = NULL;
static Timeout     sTimeOut;

static void myWaitCallback()
{
    osSignalSet(sThreadId, SIGNAL_EVENT_TIMEOUT);  // Notify thread that the timer has expired
}

static void myWait(float timeOut)
{
    sThreadId = osThreadGetId();
    bool exit = false;
    sTimeOut.attach(myWaitCallback, timeOut);
    while (!exit) {
        osEvent event = osSignalWait(SIGNAL_EVENT_TIMEOUT, osWaitForever);
        if (event.status == osEventSignal) {
            if (event.value.signals & SIGNAL_EVENT_TIMEOUT) {
                exit = true;
            }
        }
    }
    sTimeOut.detach();
}



// main() runs in its own thread in the OS
int main() {
    while (true) {
        led1 = !led1;
        //wait(0.5);
        myWait(0.5);
        Thread::wait(500);
    }
}
Parents Reply
  • Hi,

    This is very strange. Your hex file does not blink at all when flashing it on a 52840 PDK.

    Status on our own board
    Mbed 5.7.2 (with minor modifications): Hangs blinking within 2s.

    Status when flashing on 52840 PDK:
    Mbed 5.7.2 (clean OS, without any modifications): Hangs blinking within 2s.
    Mbed 5.7.6 (clean OS, without any modifications): Seems to be working fine

    With 5.7.6 it seems to be working as expected. It has been blinking for a couple of minutes now.

Children
No Data
Related