Microchip Technology DM300019 Data Sheet

Page of 50
dsPICDEM™ 80-Pin Starter Development Board User’s Guide
DS51584B-page 28
© 2006 Microchip Technology Inc.
3.4.2
Analog-to-Digital Conversion
This program consists of two subroutines which (1) perform the A/D conversion and (2) 
transmit the converted value over an RS-232 serial connection (see Figure 3-2). The 
A/D conversion routine samples the analog output of Potentiometer RB2. The transmit 
routine converts the 12-bit binary value from ADC12 to a three-digit HEX code, 
converts the HEX code to an ASCII character and loads the ASCII value into the 
transmission buffer of UART1. UART1 transmits each ASCII character with a CR and 
LF to delimit each sample as a separate line on the receiving terminal.
FIGURE 3-2:
ANALOG-TO-DIGITAL CONVERSION FLOW DIAGRAM
INIT ADC12
INIT UART
Start A/D 
Conversion
Convert HEX
Digit 3 to ASCII
ADC Complete?
Buffer Full?
Load Digit 3 into 
Transmit Buffer
START
Delay 10 msec
Convert 12-bit Binary 
to 3-digit HEX
Convert HEX
Digit 2 to ASCII
Buffer Full?
Load Digit 2 into 
Transmit Buffer
Convert HEX
Digit 1 to ASCII
Buffer Full?
Load Digit 1 into 
Transmit Buffer
Generate ASCII
CR
Buffer Full?
Load CR into 
Transmit Buffer
Generate ASCII 
LF
Buffer Full?
Load Transmit 
Buffer
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No