Lab2 - Electrical, Computer, & Telecommunications...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Electrical, Computer, & Telecommunications Engineering Technology MicroComputers Spring 20073 0618-303 Lab # 2 : Introduction to the mega128.2 Board Educational Objective: The educational objective of this laboratory is to learn how to program the mega128.2 Board. Pre-Laboratory: 1. Purchase the mega128.2 Board and bring it to lab. 2. Read and completely understand the entire procedure portion of this laboratory. 3. Enter the two attached assemble program Lab2_1 & Lab2_2 PRIOR to arriving at lab. Procedure: Echo Input 1. Using the AVR Studio 4 tool; build and simulate the attached Lab2_1 assemble program. 2. Using the “Universal Programmer User’s Guide”, program the mega128.2 Board with the Lab2_1 hex file generated in step #1. 3. Verify that the program is working. If any changes are necessary, repeat step 1 – 3 until the program is working properly. Rotating LED’s 1. Using the AVR Studio 4 tool; build and simulate the attached Lab2_2 assemble program. 2. Using the “Universal Programmer User’s Guide”, program the mega128.2 Board with the Lab2_1 hex file generated in step #1. 3. Verify that the program is working. If any changes are necessary, repeat step 1 – 3 until the program is working properly. 4. Change the delay1 variable from 0x04 to 0x40 and reprogram the mega128.2 Board. What effect did this change have on the program? Be sure to discuss this in your report write-up. 5. Make the necessary modification to the program so that the LED’s rotate from MSB to LSB. Make sure to restore variable delay1 to its original value. Documentation: Using the Lab Report Guidelines for Micro-Computers as a guide, write and submit a report for the work completed in this laboratory. Be sure to discussion the results relative to its educational objective and all observations made. Also, calculate the approximate delay for the Delay Routine that was used in the original Lab2_2 program. How does this compare to what you observed? Lab #2 Electrical, Computer, & Telecommunications Engineering Technology MicroComputers Spring 20073 0618-303 ;*************************************************************************** ;*** *** ;*** Name : Lab2_1 *** ;*** *** ;*** Description : This program continuously reads the eight *** ;*** push-button switches, performs a bit-wise inversion and outputs *** ;*** the new value to the eight LED's. This program is design to *** ;*** work on the mega128.2 board where the switches are connected to *** ;*** port-D and the LEDs are connected to port-B. *** ;*** *** ;*************************************************************************** .include "m128def.inc" ; Include the definitions file for the ; ATmega 128 microcontroller .def Data = R16 .def Temp = R17 ; Variable to be Read/Written ; Variable for temporary usage .cseg .org 0x0000 rjmp START ; Initialize the code segment (.cseg) at the ; RESET vector location 0x0000 and JUMP to ; the start of the program START: ldi Temp, 0x00 out DDRD, Temp ; Initialize PORT-D as an input port. ; PORT-D is connected to the push-button ; switches on the mega128.2 board. ldi Temp, 0xFF out DDRB, Temp ; Initialize PORT-B as an output port. PORT-B ; is connected to the LED's on the mega128.2 board in Data, PIND com Data out PORTB, Data ; ; ; ; rjmp LOOP ; Continue looping forever LOOP: Read PORT-D (switches), perform a 1's complement and Write the results to PORT-B (LED's). On the mega128.2 board the switches are normally high so the input switches and LED's will match ;*************************************************************************** Lab #2 Electrical, Computer, & Telecommunications Engineering Technology MicroComputers Spring 20073 0618-303 ;************************************************************************** ;*** *** ;*** Name : Lab2_2 *** ;*** *** ;*** Description : This program continuously displays a rotating *** ;*** pattern on the eight LED's. This program is design to work on *** ;**** the mega128.2 board where the LEDs are connected to port-B. *** ;*** *** ;************************************************************************** .include "m128def.inc" ; Include the definitions file for the ; ATmega 128 microcontroller .def .def .def .def .def ; ; ; ; ; Temp delay1 delay2 delay3 Pattern = = = = = R16 R17 R18 R19 R20 .cseg .org 0x0000 rjmp START Variable for temporary usage Delay variable 1 Delay variable 2 Delay variable 3 Variable for the pattern to be displayed ; Initialize the code segment (.cseg) at the ; RESET vector location 0x0000 and JUMP to ; the start of the program START: ldi Temp, 0xFF out DDRB, Temp ; Initialize PORT-B as an output port. PORT-B ; is connected to the LED's on the mega128.2 board ldi Pattern, 0x01 ; Initialize the pattern so just the LSB will be on out PORTB, Pattern ; ; Display the pattern. LOOP1: LOOP2: ldi delay1, 0x04 dec delay3 brne WAIT3 dec delay2 brne WAIT2 dec delay1 brne WAIT1 ; ; ; ; ; ; ; ; ; ; ; ; lsl Pattern brne LOOP2 rjmp LOOP1 ; Shift the pattern one bit to the left, if it ; not zero, continue. Otherwise jump to location ; where the pattern is reset back to the beginning. WAIT1: ldi delay2, 0xFF WAIT2: ldi delay3, 0xFF WAIT3: **** Start of Delay Routine **** * * * * * * * * * * ***** End of Delay Routine ***** ;************************************************************************** Lab #2 Electrical, Computer, & Telecommunications Engineering Technology MicroComputers Spring 20073 0618-303 Lab # 2 : Introduction to the mega128.2 Board Lab Sign-Offs Name : ______________________ Pre-Lab _______________________________________ _________________ Signature Grade (0 – 20) Echo Input _______________________________________ _________________ Signature Date Rotating LED’s (LSB MSB) _______________________________________ _________________ Signature Date Rotating LED’s (MSB LSB) _______________________________________ _________________ Signature Date Lab #2 ...
View Full Document

This note was uploaded on 01/10/2012 for the course ENG 0618-303 taught by Professor Christman during the Spring '07 term at RIT.

Ask a homework question - tutors are online