This article explains how the analog converter works.
The XC164CM provides an Analog/Digital Converter with 8-bit or 10-bit resolution and a sample & hold circuit on-chip. An input multiplexer selects between up to 14 analog input channels (alternate functions of Port 5) either via software (fixed channel modes) or automatically (auto scan modes).
Part one: using the simulator
First, you have to write a script file to make a variable voltage applied at pin AN0 (Analog converter zero). This voltage begins from a value of 5 volts and goes down by steps of 0.5 volts. It is the SQ.INI file.
Your travell: // after debuging >>Debug>Function Editor (open Ini file).
see the image
Second, after debug, you have to call this function, writing SQ() at the command window.
see it.
Take the C code.
Run it, open the serial window #1 and watch the resault.
Becarefull when you will reconfigure the project by DAVE: You have to replace line 173 made by DAVE at ASC0.C file ,with that of line 178. The problem comes from the printf function (at<stdio.h>) who calls putchar function. Printf is written for ASC0. You have to modifiy it if you want to use it with ASC1 ( see KEIL page).
Part two: using the debuger
...take it here. The program exports the voltage value at pin AN0 via ASC0 at Hyperterminal on your screen. Hyperterminal must be at 9,600 Kbaud. |