'****************************************************************
'* Name : simpleADC.BAS *
'* Author : T. Holoubek *
'* Notice : Copyright (c) 2004 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 1/3/2004 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
DEFINE OSC 4
start:
INCLUDE "modedefs.bas"
' Define ADCIN parameters
' Set number of bits in result
DEFINE ADC_BITS 10
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
' Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10
' Set PORTA to all input
TRISA = %11111111
' Set up ADCON1 analog and right justify the result
adcon1 = %10000010
'define adc vars
adcVar0 VAR WORD ' Create variable to store result
adcVar1 VAR WORD ' Create variable to store result
adcVar2 VAR WORD ' Create variable to store result
adcVar3 VAR WORD ' Create variable to store result
pause 500
main:
'
Read channel 1
ADCIN 0, adcVar0
ADCIN 1, adcVar1
ADCIN 2, adcVar2
ADCIN 3, adcVar3
'print the variable - notice the variable name is preceded by DEC
'serout2 portc.6, 16468, [DEC adcVar0, 13, 10]