Mutex: 0x20000152C. Not Allowed in ISR context. Error status: 0x80010133 Code 307 Module 1

Hello. I’m using RawSerial to read and send data to serial (on a nucleo F401RE with this mbed-os). I have an interrupt pin (used to read channel A of an encoder with 2048 pulses per revoution (i’m saying this because i’m not sure weather the baud rate could be the problem)).

The problem is when I’m trying to obj.printf("smth") (with obj declared as RawSerial obj) inside the function which is called each pulse, at the first call i got the following error code.

Untitled

  • Could the baudrate be the problem? I’ve tried 19200, 56000, 115200 but the same result I got.
  • Could a queue help me with this ?

You don’t want to printf in the ISR context. EventQueue should help.

I have an example. It’s not for GPIO interrupt. But, I think you get the idea.

and using this , what you provided how will the print happen? Could you please explain what does the mbed_event_queue? and how cound I use it on TxIrq?

This page explains the power of EventQueue.

You cannot printf in your ISR function. EventQueue makes it possible to defer the execution of printf to a user context.

Do you want interrupts on TxIrq? I thought you were using GPIO interrupts? Can you share your code?

I’m using GPIO interrupts but I was wondering if setting a TX interrupt will allow me to printf “from” my gpio interrupt ( like interrupt the gpio interrupt ) I’m not sure if it’s quite clear. The code is a little bit long but I can resume it