We First Discuss The Universal Synchronous Asynchronous Receive Transmit (USART) Protocol
We First Discuss The Universal Synchronous Asynchronous Receive Transmit (USART) Protocol
communication!
Asynchronous comm.
Asynchronous comm.
Asynchronous comm.
ASCII Letters
Things to note
Serial timing
Programmer responsibilities
RS-232
RS-232
USART0
Ability to operate full duplex (also half duplex more
later)
Register description
UCSRnA/B/C
UDRn
Used for both received AND transmitted data
Clock generation
Synchronous mode:
In asynchronous mode:
U2Xn = 1 in UCSRnA
Drawbacks (receiver):
External Clock
1-start bit
1 or 2 stop bits
Example frame
Frame format
Initialization
Straightforward:
TXEN in UCSRnB
Normal port operation on Txn is overridden
Load the transmit buffer with the data to be
transmitted
Transmitter interrupts
Transmitter interrupts
ISRs:
ISR(USARTn_UDRE_vect){//do stuff}
ISR(USARTn_TX_vect){//do stuff}
Receiver interrupt
Only one!
Effective immediately
All data pending and currently being received will be
lost
Double speed:
Address indicator
In both cases:
Registers cont.
Registers cont.
If parity is enabled
Registers cont.
Registers cont.
Registers cont.
Registers cont.
Registers cont.
Example 1 cont.
Example 1 cont.
Example 2 cont.
Example 3 cont.
Example 4 cont.
Example 4 cont.