lab four

lab four - UNIVERSITY OF CONNECTICUT ECE 3411:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
UNIVERSITY OF CONNECTICUT Fall 2011 ECE 3411: Microprocessor Application Laboratory Lab 4 Oct. 3rd, 2011, Due in Lab5 Oct. 10th lab. 1 Lab 4: AVR Serial Communications 1. Objectives Program the Universal Synchronous and Asynchronous Serial Receiver and Transmitter (USART) of AtMega644 for basic transmission and reception. Connect the microcontroller with a PC and program serial communications between them through USART and RS232. Use the AtMega644 to display basic characters on the LCD using the I2C/TWI (two wire interface) serial communications. 2. ASCII Codes: (you may need to find t he code for “Enter” key etc.) 3. Sample code - Initializing the serial communications (USART) of the microcontroller, transmitting and receiving data. /* A simple program to demonstrate the use of USART of AVR micro ************************************************************* Hardware: ATmega644 @ 1MHz
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UNIVERSITY OF CONNECTICUT Fall 2011 ECE 3411: Microprocessor Application Laboratory Lab 4 Oct. 3rd, 2011, Due in Lab5 Oct. 10th lab. 2 Suitable level converter on RX/TX line Connected to PC via RS232 PC Software : Hyper terminal @ 9600 baud No Parity,2 Stop Bit, 7 data bits Flow Control = NONE */ #define F_CPU 1000000UL #include <avr/io.h> #include <avr/interrupt.h> //This function is used to initialize the USART //at a given UBRR value void USARTInit(uint16_t ubrr_value) { //Set Baud rate UBRRL0 = ubrr_value; UBRRH0 = (ubrr_value>> 8 ); /*Set Frame Format >> Asynchronous mode >> No Parity >> 2 StopBit >> char size 7 */ UCSRC0=( (1<<USBS0))|( 2 <<UCSZ0); //Enable The receiver and transmitter UCSRB0=( 1 <<RXEN)|( 1 <<TXEN); } //This function is used to read the available data //from USART. This function will wait (poll) until data is //available. char
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

lab four - UNIVERSITY OF CONNECTICUT ECE 3411:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online