Go Down

Topic: Serial data when interrupts are disabled (Read 339 times) previous topic - next topic

TheChief79

If have a timing critical sketch, where i need to disable the interrupts sometimes to do timing critical stuff.

What happens with arriving serial data in this time? I think the arduino can't receive data when interrupts are disabled with cli(). So will the sender wait until serial can receive bytes again or are the packets lost? I'm using a leonardo with FTDI connected to pin 0 and 1.

PaulS

Quote
I think the arduino can't receive data when interrupts are disabled

Correct.

Quote
So will the sender wait until serial can receive bytes again

The sender has no idea that the receiver is ignoring serial data.

Quote
or are the packets lost?

Yes.

Quote
I'm using a leonardo with FTDI connected to pin 0 and 1.

Makes no difference.

You will probably need to implement some sort of handshaking between the sender and the receiver, so the sender know when it is safe to send.

Keep in mind that serial data reception (and sending) is not the only thing impacted by disabling interrupts. The clock can't tick, either. That is, millis() doesn't increment.

TheChief79

Quote
Keep in mind that serial data reception (and sending) is not the only thing impacted by disabling interrupts. The clock can't tick, either. That is, millis() doesn't increment.


Thank you, good to know.

holmes4

Quote
If have a timing critical sketch, where i need to disable the interrupts sometimes to do timing critical stuff.


What are you doing that's so time critical that you need to disable interrupts but still think you can use serial?

Mark

TheChief79

I'm driving a LED strip with 240 WS2811 LEDs and FastSPI_LED or WS2811.h. Both disables the interrupts while outputting the data to the LED strips. If any data is send through serial in this time, some packages are lost.

http://bleaklow.com/2012/12/02/driving_the_ws2811_at_800khz_with_a_16mhz_avr.html

Go Up