
- •Features
- •Pin Configuration
- •Description
- •Block Diagram
- •Pin Descriptions
- •Port A (PA7..PA0)
- •Port B (PB7..PB0)
- •Port C (PC7..PC0)
- •Port D (PD7..PD0)
- •Port E (PE2..PE0)
- •RESET
- •XTAL1
- •XTAL2
- •Crystal Oscillator
- •EEPROM Data Memory
- •SRAM Data Memory
- •I/O Direct
- •Data Direct
- •Data Indirect with Displacement
- •Data Indirect
- •l/O Memory
- •Status Register – SREG
- •Stack Pointer – SP
- •Reset Sources
- •Power-on Reset
- •External Reset
- •Brown-out Detection
- •Watchdog Reset
- •Interrupt Handling
- •Interrupt Response Time
- •External Interrupts
- •Sleep Modes
- •Idle Mode
- •Power-down Mode
- •Power-save Mode
- •Timer/Counters
- •Timer Counter0 – TCNT0
- •Timer/Counter2 – TCNT2
- •Timer/Counter1
- •Timer/Counter1 in PWM Mode
- •Watchdog Timer
- •SS Pin Functionality
- •Data Modes
- •SPI Control Register – SPCR
- •SPI Status Register – SPSR
- •SPI Data Register – SPDR
- •UARTs
- •Data Transmission
- •Data Reception
- •UART Control
- •Baud Rate Generator
- •Analog Comparator
- •Interface to External Memory
- •I/O Ports
- •Port A
- •Port A Data Register – PORTA
- •Port A as General Digital I/O
- •Port A Schematics
- •Port B
- •Port B Data Register – PORTB
- •Port B as General Digital I/O
- •Port B Schematics
- •Port C
- •Port C Data Register – PORTC
- •Port C as General Digital I/O
- •Port C Schematics
- •Port D
- •Port D Data Register – PORTD
- •Port D as General Digital I/O
- •Alternate Functions of Port D
- •Port D Schematics
- •Port E
- •Port E Data Register – PORTE
- •Port E as General Digital I/O
- •Alternate Functions of Port E
- •Port E Schematics
- •Boot Loader Support
- •Setting the Boot Loader Lock Bits by SPM
- •Performing Page Erase by SPM
- •Fill the Temporary Buffer
- •Perform a Page Write
- •Reading the Fuse and Lock Bits from Software
- •Fuse Bits
- •Signature Bytes
- •Parallel Programming
- •Signal Names
- •Enter Programming Mode
- •Chip Erase
- •Programming the Flash
- •Programming the EEPROM
- •Reading the Flash
- •Reading the EEPROM
- •Programming the Fuse Bits
- •Programming the Lock Bits
- •Reading the Signature Bytes
- •Serial Downloading
- •Data Polling Flash
- •Data Polling EEPROM
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •External Data Memory Timing
- •Ordering Information
- •Packaging Information

Data Reception
Figure 46 shows a block diagram of the UART receiver.
Figure 46. |
UART Receiver |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DATA BUS |
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UART I/O DATA |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
BAUD x 16 |
|
|
|
BAUD |
REGISTER (UDRn) |
|
|||||||||
XTAL |
|
|
|
BAUD RATE |
/16 |
|
|
||||||||||||||||||||
|
|
|
|
|
|
|
|
||||||||||||||||||||
|
|
|
|
|
|||||||||||||||||||||||
|
|
|
GENERATOR |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STORE UDRn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
PIN CONTROL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
LOGIC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PD0/ |
|
|
|
|
|
|
RXDn |
DATA RECOVERY |
|
|
|
|
|
10(11)-BIT RX |
|
||||||||||
|
|
|
|
|
|
|
|
|
|||||||||||||||||||
|
|
PB2 |
|
|
|
|
|
|
|
|
|
LOGIC |
|
|
|
|
|
SHIFT REGISTER |
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RXENn |
TXENn |
CHR9n |
RXB8n |
TXB8n |
RXCn |
TXCn |
UDREn |
FEn |
ORn |
U2Xn |
MPCMPn |
|
UART CONTROL AND |
|
UART CONTROL AND |
|||||||||
|
STATUS REGISTER |
|
STATUS REGISTER |
|||||||||
|
|
|
|
(UCSRnB) |
|
|
(UCSRnA) |
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RXCIEn |
TXCIEn |
|
UDRIEn |
|
|
|
DATA BUS |
TXCn |
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n = 0,1 |
RXCn |
IRQ |
The receiver front-end logic samples the signal on the RXDn pin at a frequency 16 times the baud rate. While the line is idle, one single sample of logical “0” will be interpreted as the falling edge of a start bit, and the start bit detection sequence is initiated. Let sample 1 denote the first zero-sample. Following the 1-to-0 transition, the receiver samples the RXDn pin at samples 8, 9 and 10. If two or more of these three samples are found to be logical “1”s, the start bit is rejected as a noise spike and the receiver starts looking for the next 1-to-0 transition.
If, however, a valid start bit is detected, sampling of the data bits following the start bit is performed. These bits are also sampled at samples 8, 9 and 10. The logical value found in at least two of the three samples is taken as the bit value. All bits are shifted into the transmitter shift register as they are sampled. Sampling of an incoming character is shown in Figure 47. Note that the description above is not valid when the UART transmission speed is doubled. See “Double-speed Transmission” on page 77 for a detailed description.
70 ATmega161(L)
1228B–09/01

ATmega161(L)
Figure 47. Sampling Received Data(1)
Note: 1. This figure is not valid when the UART speed is doubled. See “Double-speed
Transmission” on page 77 for a detailed description.
|
When the stop bit enters the receiver, the majority of the three samples must be one to |
|
accept the stop bit. If two or more samples are logical “0”s, the Framing Error (FEn) flag |
|
in the UART Control and Status Register (UCSRnA) is set. Before reading the UDRn |
|
register, the user should always check the FEn bit to detect framing errors. |
|
Whether or not a valid stop bit is detected at the end of a character reception cycle, the |
|
data is transferred to UDRn and the RXCn flag in UCSRnA is set. UDRn is in fact two |
|
physically separate registers, one for transmitted data and one for received data. When |
|
UDRn is read, the Receive Data register is accessed, and when UDRn is written, the |
|
Transmit Data register is accessed. If 9-bit data word is selected (the CHR9n bit in the |
|
UART Control and Status Register [UCSRnB] is set), the RXB8n bit in UCSRnB is |
|
loaded with bit 9 in the Transmit shift register when data is transferred to UDRn. |
|
If, after having received a character, the UDRn register has not been read since the last |
|
receive, the OverRun (ORn) flag in UCSRnB is set. This means that the last data byte |
|
shifted into the shift register could not be transferred to UDRn and has been lost. The |
|
ORn bit is buffered and is updated when the valid data byte in UDRn is read. Thus, the |
|
user should always check the ORn bit after reading the UDRn register in order to detect |
|
any overruns if the baud rate is high or CPU load is high. |
|
When the RXEN bit in the UCSRnB register is cleared (zero), the receiver is disabled. |
|
This means that the PD0 pin can be used as a general I/O pin. When RXEN is set, the |
|
UART receiver will be connected to PD0 (UART0) or PB2 (UART1), which is forced to |
|
be an input pin regardless of the setting of the DDD0 in DDRD (UART0) or DDB2 bit in |
|
DDRB (UART1). When PD0 (UART0) or PB2 (UART1) is forced to input by the UART, |
|
the PORTD0 (UART0) or PORTB2 (UART1) bit can still be used to control the pull-up |
|
resistor on the pin. |
|
Note that PB2 (UART1) also is used as one of the input pins to the Analog Comparator. |
|
It is therefore not recommended to use UART1 if the Analog Comparator also is used in |
|
the application at the same time. |
|
When the CHR9n bit in the UCSRnB register is set, transmitted and received characters |
|
are nine bits long plus start and stop bits. The ninth data bit to be transmitted is the |
|
TXB8n bit in UCSRnB register. This bit must be set to the wanted value before a trans- |
|
mission is initiated by writing to the UDRn register. The ninth data bit received is the |
|
RXB8n bit in the UCSRnB register. |
Multi-processor |
The Multi-processor Communication Mode enables several slave MCUs to receive data |
Communication Mode |
from a master MCU. This is done by first decoding an address byte to find out which |
|
MCU has been addressed. If a particular slave MCU has been addressed, it will receive |
|
the following data bytes as normal, while the other slave MCUs will ignore the data bytes |
|
until another address byte is received. |
|
For an MCU to act as a master MCU, it should enter 9-bit transmission mode (CHR9n in |
|
UCSRnB set). The ninth bit must be one to indicate that an address byte is being trans- |
|
mitted, and zero to indicate that a data byte is being transmitted. |
71
1228B–09/01