SERIAL COMMUNICATION IN ATMEGA 16 Suren Kumar @ embedautomation.com
Lets get started Wiki:- S erial Port is a serial communication physical interface through which information transfers in or out one bit at a time (contrast parallel port). Throughout most of the history of personal computers, data transfer through serial ports connected the computer to devices such as terminals and various peripherals. While such interfaces as Ethernet, FireWire, and USB all send data as a serial stream, the term "serial port" usually identifies hardware more or less compliant to the RS-232 standard, intended to interface with a modem or with a similar communication device.
In digital circuits, a shift register is a group of flip flops set up in a linear fashion which have their inputs and outputs connected together in such a way that the data is shifted down the line when the circuit is activated.
- to handle start/stop bit framing, parity bit, shift register.
- to receive a character through RxD pin.
- to perform the reverse operation of the transmitter.
- to configure, control and monitor the serial USART.
USART Baud Rate Registers The UBRRH Register shares the same I/O location as the UCSRC Register. See the “Accessing UBRRH/ UCSRC Registers” on page 155 section which describes how to access this register. • Bit 15 – URSEL: Register Select :- This bit selects between accessing the UBRRH or the UCSRC Register. It is read as zero when reading UBRRH. The URSEL must be zero when writing the UBRRH. • Bit 14:12 – Reserved Bits :- These bits are reserved for future use. For compatibility with future devices, these bit must be written to zero when UBRRH is written. • Bit 11:0 – UBRR11:0: USART Baud Rate Register :- This is a 12-bit register which contains the USART baud rate. The UBRRH contains the four most significant bits, and the UBRRL contains the 8 least significant bits of the USART baud rate. Ongoing transmissions by the transmitter and receiver will be corrupted if the baud rate is changed. Writing UBRRL will trigger an immediate update of the baud rate prescaler.
USART Baud Rate Registers Example: Find UBRR registers for baud rate of 1200bps, assuming system clock is 1MHz. Ans: UBRR = 1000000/(16 × 1200) ─ 1 = 51d = 0033H. Therefore, UBRRH = 00H and UBRRL = 33H. C code UBRRH = 0x00; UBRRL = 0x33;