Pages: [1]   Go Down
Author Topic: Serial data when interrupts are disabled  (Read 332 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50949
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2396
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: