The first lab session will be used to ensure that each student is ready to use their laptop and development board to develop assembly programs the rest of the quarter.
.hex, file to your microcontroller using ATmon and run it.
The following program toggles LEDs in response to buttons on the keypad being toggled. In order of this program to work correctly, the LED board must be connected to PORTB and the keypad must be connected to PORTC.
; lab0.asm
; Causes an LED to toggle on/off when a switch from
; on the keypad is toggled.
;
; Specifically, if any key in row X is depressed, LED Y
; turns off, where 0 < X < 5 and Y = X + 4. For example,
; Depressing a key in row one of the keypad causes L5 on
; the LED board to turn off. When all of the keys in a
; row are released, the corresponding LED turns on.
;
; CONFIGURATION
; - The LED board must be connected to PORTB.
; - The keypad must be connected to PORTC.
;
; Course: CE2800-002 Winter 2007-2008
; Assignment: Lab 0
; Author: t a y l o r@msoe.edu
; Date: 11-26-2007
.nolist
.include "m32def.inc"
.list
.def temp = r16 ; Use R16 as a temp register
.cseg ; Begin code segment
.org 0
rjmp init ; Initialize restart vector
.org 0x2a
; Initializes PORTB and PORTC.
; Requires LEDs be connected to PORTB and keypad to PORTC.
init:
ldi temp, 0x0f ; Set keypad cols as output, rows as input
out DDRC, temp
ldi temp, 0xf0 ; Enable pull-up resistors on PORTC4-7
out PORTC, temp
ldi temp, 0xff ; Configure PORTB as an output port
out DDRB, temp
; main - Continually scans keypad and sends results to LEDs.
; Requires LEDs be connected to PORTB and keypad to PORTC.
main:
in temp, PINC ; Read rows of keypad from PORTC
out PORTB, temp ; Display results on LEDs 5-8
rjmp main ; Repeat main
Follow the instructions for making a new project in AVR Studio in order to build the .hex that that gets downloaded to the microcontroller.
Follow the ATmon User's Guide for instructions on how to download the .hex file to the microcontroller.