160 likes | 347 Views
University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering. Microcontroller Lab. 4:. Serial communication using USART module. In this session. Review the previous session. How to interface and use LCDs. How to interface Keypads.
E N D
University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering Microcontroller Lab. 4: Serial communication using USART module
In this session • Review the previous session. • How to interface and use LCDs. • How to interface Keypads. • To implement serial communication between MCU and PC using USART.
LCD Device • A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating properties of liquid crystals (LCs). • They are common in consumer devices such as video players, gaming devices, clocks, watches, calculators, and telephones.
Serial Communication • Terminologies • Synchronization of Serial Transmission: allows both the transmitter and receiver to be expecting data transmission/ reception at the same time. • There are two basic methods of maintaining ‘‘sync’’: • - Asynchronous: Framing bits are used at the beginning and end of a data byte which alert the receiver that an incoming data byte has arrived and also signals the completion of the data byte reception. • - Synchronous: Data bits are sent and received on the edge of common clock.
Serial Communication • Terminologies • Baud Rate: Data transmission rates which is specified as a baud or bits per second rate. • Duplex: A single duplex system has a single complement of hardware that must be switched from transmission to reception configuration.
Serial USART • The ATmega32 is equipped with different serial communication subsystems, including the serial USART, SPI, and TWI. • USART: Universal Synchronous and Asynchronous serial Receiver and Transmitter. • - Full duplex. • - It has the capability to be set to a variety of data • transmission rates rate.
Serial USART • The initialization process of USART normally consists of - Setting the baud rate. - Setting frame format. - Enabling the Transmitter or/and the Receiver depending on the usage. - For interrupt driven USART operation, the Global Interrupt Flag should be cleared (and interrupts globally disabled) when doing the initialization
Frame Formatting • A serial frame is defined to be one character of data bits with synchronization bits (start and stop bits), and optionally a parity bit for error checking.
USART Registers - USART I/O Data Register (UDR) The USART Transmit Data Buffer Register and USART Receive Data Buffer Registers share the same I/O address referred to as USART Data Register or UDR. • USART Control and Status Register A – (UCSRA) Bit 7 – RXC: USART Receive Complete This flag bit is set when there are unread data in the receive buffer and cleared when the receive buffer is empty (i.e., does not contain any unread data).
Frame Formatting • - Bit 5 – UDRE: USART Data Register Empty • The UDRE Flag indicates if the transmit buffer (UDR) is ready to receive new data. If UDRE is one, the buffer is empty, and therefore ready to be written.
MAX232 • Logic Convertor