Error Status 0x80010133 Code: 307 Module: 1 Error Message: Mutex 0x100017BC, NOt allowed in ISR Context

EDIT 2: Now i’m trying Jojo’s Queue idea but now i’m struggling trying to put function calls inside queues, I make a queue with:

Queue<std::function<void()>, 4> movementCommandQueue;

and try to put a no input void() function like:

movementCommandQueue.put(fwd, 10);

and I get the error:

argument of type "void (*)()" is incompatible with parameter of type "std::function<void ()> *"

Using a function as a parameter like this works when I look at std docs for functions as parameters but not with Queue? Also, I tried to change queue to different format I saw for using functions as parameters like:

Queue<(void(*)), 4> movementCommandQueue;

but then I get the error:

expected a type specifier

EDIT: no longer trying to put a function inside a function inside a thread, but now I have a new runtime error trying to run a thread by its self

Im trying to call a command to move my wheels in a separate thread, but allow it to be interrupted with a new command/lack of new command being executed in the main thread, but I get this memory related error at runtime. Is there something I forgot to do?

Im using an LPC1768 if that’s relevant


//placeholder function to erase previously queued command

 void placeholder(){

//function i’m trying to call

void fwd() { 
    //Allows wheels to move
    xEN = 0;
    yEN = 0;

    //Sets direciton to hopefully forward
    xDIR = 1;
    yDIR = 0;

                xSTP = 1;
                ySTP = 1;
                xSTP = 0;
                ySTP = 0;

//In command manager function


//In main

That’s simply not possible, the thread function must not have arguments.
You can create a helper class with a thread, the thread function and the commands, then the thread function has access to the commands or other class members.

I realized my approach was probably bad and tried a new approach of having a thread with the movement command executing infinitely until a new movement command is issued or if none of the movement keys are pressed but I get some kind of memory error now ;-;


This topic seems chaotic, it would be good to comb it a little.
First topic name was about pass arguments into thread, now is about Mutex in ISR but no ISR code is visible and last information is about unspecified memory error.

BR, Jan

it is not nice to completely change a threads title and the content of a posting, you see the confusion here.

I would strongly avoid to terminate a thread, creating and deleting threads is expensive and in most cases not necessary.
Instead, look for lPC, inter process communication. You can use a Queue to pass commands to the command manager thread, there is an example in the API docs.

Ah, sorry, didn’t think deleting this post and posting a new one would be good either so I did this.

As for the queue idea, I’m looking into it now but I don’t see an option to empty the queue? I don’t see a clear function for Queues. How would I clear the queue without executing the things inside it?

EDIT: New error, again, details in main post

a Queue for functions is an EventQueue in Mbed.

Code, and what is it trying to do?