InterruptIn MbedOS error

Hello, friends!

Board: Nucleo-F303RE
IDE: Mbed Studio

Code: Simple code from InterruptIn manual page

#include “mbed.h”

using ThisThread::sleep_for;

InterruptIn button(BUTTON1); // define and name the interrupt input
DigitalOut led(PA_5);
DigitalOut flash(PA_7);

void ISR1() //this is the response to interrupt, i.e. the ISR
led = 1;
led = 0;

int main()
button.rise(&ISR1); // attach the address of the ISR function to the
// interrupt rising edge
while(1) // continuous loop, ready to be interrupted
flash = !flash;

Any InteruptIn button press fails with this error. No matter what interrupt code is. And no matter what the other code is. Whenever InterruptIn button pressed it fails. As well, LED1 constantly flashes with such a combination: …----- where dot is short blink and dash - long one.
Please, help to recognize the problem.

++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: status == osOK
Location: 0x8004B0F
File: ThisThread.cpp+227
Error Value: 0x0
Current Thread: rtx_idle Id: 0x20001C70 Entry: 0x80059FD StackSize: 0x280 StackMem: 0x20001D40 SP: 0x2000FEF4
For more info, visit: mbedos-error
– MbedOS Error Info –

1 Like


It is not like you write. It depends on the code. The problem is the delay in ISR.

void ISR1() //this is the response to interrupt, i.e. the ISR
   led = 1;
   sleep_for(3s); // this is wrong
   led = 0;

BR, Jan

Thank you for the answer. But as I said, any InterruptIn code fails with an error. Any activation of interrupt assigned button ends with it.
I just tried sligtly modified InterruptIn hello, world code from manpage. Modified parts are in bold. Ends with an error.


  • Copyright (c) 2017-2020 Arm Limited and affiliates.
  • SPDX-License-Identifier: Apache-2.0

#include “mbed.h”

InterruptIn button (BUTTON1);
DigitalOut led(LED1);
DigitalOut flash (D10);

void flip()
led = !led;

int main()
button.rise(&flip); // attach the address of the flip function to the rising edge
while (1) { // wait around, interrupts will interrupt this!
flash = !flash;
ThisThread::sleep_for (1s);

I tried your code before I wrote my first post. Your code failed with the MbedOS Error only with sleep_for in ISR

My setup:

  • Nucleo-F303RE
  • latest MbedStudio
  • MbedOS 6.17
  • Both your codes, but without sleep_for in ISR

Working as expected.

Try to perform mass erase via STM32CubeProgrammer and Clean Build in MbedStudio.

BR, Jan

The same thing. Maybe the board is broken?

This is strange. Can you try output from KeilStudio?

Do you mean KeilStudio Cloud?

Yes, sorry. Correct name is Keil Studio Cloud (KSC). KSC is easy to use and very similar to MbedStudio, because it was MbedStudio Online in the past. But to be honest it is more handy than MbedStudio at this moment because current developlment is focused on KSC. Of cource every coin has two sides, but don’t be afraid for basic things it is very easy to undestand.

Arm Keil Studio Cloud User Guide

Do not be hesitate to ask if you need help.

BR, Jan

Strange things, but the code is working in KSC. Moreover, it’s already working in Mbed Studio. What was the continuity?

  1. In KSC I did “Run program” - errors.
  2. In KSC - “Clean build” and put the bin to the controller flash drive - success!
  3. “Run program” again - Success.
  4. Switch to Mbed Studio. “Run program” - errors.
  5. “Clean build” and “Run program” - success!

Maybe, I should reinstall Mbed Studio?

Hard to say what is the rootcause, but I also fased strange things a time ago. Where the IDE absolutly ignored changes in code and only upload still one same binary file. That is why I wrote about Clean Build above.

KSC upload wrong binary - Keil Studio - Arm Mbed OS support forum

So I usually check the log and when there is no info about compilation of changed file not pressend (and I know I made some changes) then I know something is wrong.

compile main.cpp
Build succeeded

BR, Jan

Thank you for help!