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;
sleep_for(3s);
led = 0;
}
int main()
{ //button.mode(PullUp);
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;
sleep_for(1s);
}
}
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 –
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.
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);
}
}
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.
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.
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.