The purpose gain experience with the Analog to Digital Converter circuitry.
Problem Statement
In this lab, you will design, code, assemble, simulate, download and run
a program. Your program should read the voltage across the potentiometer
on the STK200 using the analog to digital converter and display the digital
value that results as a hexidecimal number on the LCD display.
Program Notes:
In order to complete this assignment you should place the following
functions (written as part of the lab 5
assignment) in a file called lcdLibrary.asm:
delay2ms -- provides a 2ms delay when
called
lcdPortInit -- configures all ports
needed to use the LCD
lcdInit -- sends a sequence of
initialization commands to LCD
lcdCmdWrite -- writes the command
stored in R20 to the LCD (you may use the code from the wiki)
lcdDataWrite -- writes the data
stored in R20 to the LCD
lcdClear -- clears the LCD and sends
the cursor home
lcdStringWrite -- writes a
null-terminated string stored in program memory (indicated by the
Z pointer) to the LCD
convertLowerNibble -- converts lower
nibble of r20 into its ASCII equivalent (you may use the code from
the wiki)
You should update any of the functions above, if needed, based
on things you have learned. Be sure to document any updates.
Your program for this assignment should make use of the following
new functions:
lcdPrint -- converts the value stored
in R20 into two ASCII characters, the hexadecimal representation,
and displays them on the LCD
getADC -- accepts an ADC channel
(passed via R24) and returns the result of the analog to digital
conversion on the specified channel, returned via R24
To use the potentiometer as an analog you must install a jumper
connecting pins 1 and 2 on the 5-pin analog header located just
above the ATmega32 chip. This connects the potentiometer output
to ADC channel 3.
Keep in mind that both the ADC and the LCD make use of PORTA.
When talking to the ADC, PA3 must be configured as an
input pin. When talking to the LCD, the entire PORTA must
be configured for output.
At the end of your program file, you should
.include "lcdLibrary.asm" so that those
function get assembled.
Pre-laboratory activity (due on entering the week 7 lab)
Prior to entering the room, you must submit your updated and documented
lcdLibrary.lst file using the
online submission form.
Laboratory Demonstration (due 5pm the day prior to the week 8 lab)
You must demonstrate your program working on your board.
Laboratory Report (due 11pm the day prior to the week 8 lab)
In addition to the standard documentation, your source file should contain
a couple of sentences that describe what you think would be most useful for
you to write about related to this assignment.
Also, you must log the time you spent on this assignment (including
the pre-laboratory activity) in FAST
(in the week 7 column).
Acknowledgment
This assignment is based on a similar assignment developed by
Prof. Bill Barnekow.
I am responsible for all content posted on these pages; MSOE is welcome to share these opinions but may not want to.