For those who are interested in the code i ended up using, mabe it helps someone out there, i used the 16F877 micro
INCLUDE "MODEDEFS.BAS"
DEFINE OSC 20 ' Define crystal as 20Mhz
'Define ACDIN parameters
Define ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source ( 3 = RC )
DEFINE ADC_SAMPLEUS 50 ' Set sampling time to micro-seconds
'This Part set PORTA 0-5 an analog inputs
TRISA = %00011111 'set PORTA 0-5 as inputs
ADCON1 = %10000010 'Right justify output of ADC use vss and vdd as ref.
ADCON0 = %11100000 'FRC (clock derived from a dedicated internal oscillator)
TRISC = %10000000 'RC7 as RX(input) rest as output
TRISD = %11110000 'Set port d 0-3 as outputs and 4-7 as inputs
TRISB = %10011000
TRISE = %00000001
'Configure debug out
DEFINE DEBUG_REG PORTB
DEFINE DEBUG_BIT 2
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
'Configure debug in
DEFINE DEBUGIN_REG PORTE
DEFINE DEBUGIN_BIT 0
DEFINE DEBUGIN_BAUD 2400
DEFINE DEBUGIN_MODE 0
UPS VAR BYTE[46]
MAIN:
DEBUG "MAIN PROGRAM",13,10
PAUSE 2000
GOSUB READUPS
DEBUG str ups\45,13,10
goto MAIN
READUPS:
DEBUG "READ UPS SUBRUTINE",13,10
SEROUT PORTE.1,T2400,["Q1",13]
DEBUGIN 200,MAIN,[STR UPS\45]
RETURN
END
Bookmarks