For those who are also trying this here is a working program reading the 5 analog channels on a 16F913 and sending it out on the serial port, hope this will help someone having a few less sleeples nights, thank you for everyone who helped me get this far
INCLUDE "ANSI.INC"
DEFINE OSC 20 ' Define crystal as 20Mhz
'*Serial port Setup 9600 8N1*
DEFINE HSER_BAUD 9600 ; 9600 Baud
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ; Clear overflow automatically
'*ADC setup*
DEFINE ADC_BITS 10 'SETS NUMBER OF BITS IN RESULTS 8,10,12
DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS
'This Part set PORTA 0-5 an analog inputs
ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
ANSEL = %00011111 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
TRISA = %00011111 'set PORTA 0-5 as inputs
ADCON0.7 = 1 'Right justify output of ADC datasheet P145 of 16F913
TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2
INTCON = 0 ;Disable interrupts
V1 var word
V2 var word
V3 var word
V4 var word
V5 var word
loop:
@ ClearScr ; Clear Screen
ADCIN 0,V1
ADCIN 1,V2
ADCIN 2,V3
ADCIN 3,V4
ADCIN 4,V5
HSEROUT ["Value of ADCIN 0 = ",dec V1,10,13]
HSEROUT ["Value of ADCIN 1 = ",dec V2,10,13]
HSEROUT ["Value of ADCIN 2 = ",dec V3,10,13]
HSEROUT ["Value of ADCIN 3 = ",dec V4,10,13]
HSEROUT ["Value of ADCIN 4 = ",dec V5,10,13]
PAUSE 500
goto loop
END




Bookmarks