Mutex error with official CAN class reference example


I tried using the example of this API reference: CAN - API references and tutorials | Mbed OS 6 Documentation
Even after removing the printf-statements, the device gives me back the following error:

++ MbedOS Error Info ++
Error Status: 0x80010133 Code: 307 Module: 1
Error Message: Mutex: 0x20002CBC, Not allowed in ISR context
Location: 0x800211F
Error Value: 0x20002CBC
Current Thread: rtx_idle Id: 0x20001170 Entry: 0x800212D StackSize: 0x200 StackMem: 0x200014B8 
SP: 0x2001FEDC 
For more info, visit:
-- MbedOS Error Info --

I even isolated the call can1.write from the if-loop showing, that it is exactly the can1.write call which causes the issue. It seems like the example cannot run on MbedOS 6.7, although it is shown as such. Is there any other possibility to try out this example? I am running my code on a Nucleo-f446re.

Best regards



Form my point of view, it is not related to current version of MbedOS. That will happen with all versions of MbedOS 5.12 +.
Fastest is switch to the bare metal profile probably. Or a variant with EventQueue.

For EventQueue click here
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
CAN can2(PB_8, PB_9);
CAN can1(PB_12, PB_13);
//EventQueue queue(32 * EVENTS_EVENT_SIZE);
//Thread t;
char counter = 0;
void send() {
    if(can1.write(CANMessage(1337, &counter, 1))) {
        printf("Message sent: %d\n", counter);
        led3 = !led3;
int main() {
     EventQueue *queue = mbed_event_queue();
    //t.start(callback(&queue, &EventQueue::dispatch_forever)); 
    queue->call_every(1s, send); 
    CANMessage msg;
    while(1) {
        if( {
            printf("Message received: %d\n",[0]);
            led2 = !led2;
        led1 = !led1;

BR, Jan