AVR tutorial 5


Using the AVR ADC.

Last change : 13 November 2006 recompiled using WinAVR 20060412.

3 November 2005 : compiled using WinAVR 20040404.

On reception of data from the serial port, the AVR does a Analogue to digital conversion on channel 0 and transmits the results back via the serial port in ascii hex.

Circuit diagram



Software.

The files included :
serial.gif : the above circuit diagram.
main.c : the main c application.
uart001.c : the uart routines.
uart001.h : the header file used by main.c for the function prototypes.
uart001.inc : a file used by main.c and uart001.c for constants and defines.
adc001.c : the adc routines.
adc001.h : the header file used by main.c for the function prototypes.
adc001.inc : a file used by main.c and adc001.c for constants and defines.
makefile : the file created by AVRMakeGen.

Download (20KB) the software and diagram in one Zip.

Serial setup.

9600 baud.
1 stop bit.
0 parity bits.
Full duplex

For a terminal application, use Hyper Terminal or the terminal application found here.


How to.

To build your project simply extract all the files to the same directory.
Next, using programmers note pad, open main.c.
Now click on tools and then on make all.

Note: The provided makefile is generated for a SP12 type programmer as shown in tutorial 2. If you are using a different programmer you'll have to edit the makefile.

Program the device, insert it into the circuit and plug the db9 into your PC's serial port.
Power up the circuit, provide a 0..5V signal to pin 23 and send a key via the terminal application. Each keystroke triggers a new conversion.

Forward to tutorial 6

Home mail add