Closed vyruz1986 closed 1 year ago
Did you figure this out? I'm trying to use a queue as well for me interrupt
Hi,
You can't use a queue this way in Arduino because you should never call malloc() in an ISR. Also, you can't use a mutex because an ISR should never block. Take a look at the documentation for Arduino's attachInterrupt():
https://www.arduino.cc/en/Reference/AttachInterrupt
That shows an ISR setting a variable declared 'volatile' and the main loop checking that variable. Your implementation must follow that pattern.
Hi,
I am trying to use this library to have a FIFO buffer for ISR's. In the ISR I am calling the
push()
member function of astd::queue
object like so:However the last line of this code causes my arduino to freeze. After I posted this question on arduino.stackexchange, I got a comment from someone who implies the freeze is caused by 'malloc() not being reentrant
, and since the
.push()` member function of a queue tries to allocate memory, it causes the freeze.Is there any way around this? I really need a FIFO buffer for my ISR's, and wouldn't know how to achieve this other than using an
std::queue
container (or similar).