Serial interrupts - hardware serial

I'm having trouble understanding RS-232 interrupts in Arduino. Please also understand that I am using HARDWARE serial ports, and I'm actually using a TEENSY 3.2 board.

I believe that if I use issue the command

if Serial.available()

an interrupt-driven hardware USART will be invoked and put incoming bytes into a buffer, and that I need to do nothing to enable the hardware interrupt except issue the "Serial.available()" command.

Is all the above true? How big is the receive buffer?

Is there a buffer overflow flag? What happens if the buffer is overflowed?

And, if I use the command

Serial.write(x)

is that interrupt-driven as well? To be more clear, if I want to send a binary array, will the code load one byte into the transmit buffer and continue before the character is actually sent? Is there some function that will allow me to simply pass an array to a routine, and it will 'automatically' be sent in the background?

Do I have to send each element of the array separately to the Serial.write() routine, or is there some other library or function that will allow me to just pass the array and a pointer to a routine and it will be sent?

I must receive and send serial data from several ports simultaneously. The program cannot be blocked during character SEND or RECEIVE times. All reception and transmission must occur in the background.

If someone has an example of what I'm trying to do, I would be very appreciative.

it is not RS232. it is TTL.

you can look for all this details you ask into source code as I did.

btw: Arduino was developed for artists to create interactive electronic art. they do not care how it is implemented.

More answers here

I believe that if I use issue the command

if Serial.available()

an interrupt-driven hardware USART will be invoked and put incoming bytes into a buffer,

Serial.available() tells you how many bytes are already in the buffer. Serial.begin(baudRate) starts the Serial interface at the specified baud rate ready to send and receive data

CharlesLinquist:
I believe that if I use issue the command

if Serial.available()

an interrupt-driven hardware USART will be invoked and put incoming bytes into a buffer, and that I need to do nothing to enable the hardware interrupt except issue the "Serial.available()" command. Is all the above true?

All available does is tell you if there is data in the receive buffer that you haven't read out yet. It doesn't create anything. It just looks at the circular receive buffer and checks if there is anything in there.

CharlesLinquist:
How big is the receive buffer?

64 bytes.

CharlesLinquist:
Is there a buffer overflow flag? What happens if the buffer is overflowed?

If the receive buffer overflows then you start to lose data. Make sure you read it out fast enough to keep that from happening.

CharlesLinquist:
And, if I use the command

Serial.write(x)

is that interrupt-driven as well?

Yes.

CharlesLinquist:
To be more clear, if I want to send a binary array, will the code load one byte into the transmit buffer and continue before the character is actually sent? Is there some function that will allow me to simply pass an array to a routine, and it will 'automatically' be sent in the background?

The send buffer is also 64 bytes. When you call write or print all you are doing is putting your data into that buffer. The data in the buffer is then sent out via an interrupt driven process.

CharlesLinquist:
Do I have to send each element of the array separately to the Serial.write() routine, or is there some other library or function that will allow me to just pass the array and a pointer to a routine and it will be sent?

Why don't you take a minute to read up on the subject. There is a ton of information out there on how to use Serial with the Arduino. Yes there are commands to send whole arrays of bytes at a time. This sort of thing is all covered in the documentation and then there are beginner to advanced level tutorials on this site, on the forum, on the internet, really anywhere you look.

CharlesLinquist:
I must receive and send serial data from several ports simultaneously. The program cannot be blocked during character SEND or RECEIVE times. All reception and transmission must occur in the background.

Yes, that's how Serial communication works.

CharlesLinquist:
If someone has an example of what I'm trying to do, I would be very appreciative.

There are thousands. Perhaps you should do a little searching instead of expecting someone to write a whole one-off complete tutorial just special for you. Believe me, you aren't the first n00b who wants to use the serial port.

CharlesLinquist:
I believe that if I use issue the command

if Serial.available()

an interrupt-driven hardware USART will be invoked and put incoming bytes into a buffer, and that I need to do nothing to enable the hardware interrupt except issue the "Serial.available()" command.

Is all the above true?

No.

From the moment the Arduino starts the USART causes an interrupt whenever a character is received and the Interrupt Service Routine adds the character to the serial input buffer which is 64 bytes long on an Uno or Mega. If the buffer is full extra bytes that arrive are lost. I don't have a Teensy but I presume the buffer is the same size - I can't see any need for a bigger buffer.

The Serial.available() function just tells you how many bytes are in the buffer.

If you use code like in the 2nd and 3rd examples in Serial Input Basics the received data will be transferred to an array of whatever size you choose long before the 64 byte buffer is full.

...R