OK, I got it....
I ended up doing like this in the end :
@ DEVICE XT_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE LOADER_USED 1
Include "Modedefs.Bas"
Define OSC 4 ' We're using a 4MHz Resonator
define DEBUG_REG PORTB ' DEBUG PORT
DEFINE DEBUG_BIT 6 ' *** Debug pin Bit ***
DEFINE DEBUG_BAUD 2400 ' *** Debug Baud Rate ***
Define DEBUG_MODE 1 ' Set Serial Mode 0=True, 1=Inverted
Define DEBUG_PACING 500 ' Delay 'in Us' between characters sent
CLR CON 1 ' CLR LCD command
LINE1 CON 128 ' LCD line #1
LINE2 CON 192 ' LCD line #2
LINE3 CON 148 ' LCD line #3
LINE4 CON 212 ' LCD line #4
INS CON 254 ' LCD command mode parameter
' ** Port configurations **
TX VAR PORTB.5 ' Bootloader connection for TX
RX VAR PORTB.2 ' Bootloader connection for RX
PIEZO var PORTB.7 ' On board Piezo
IR_REC VAR PORTA.3 ' On board Infrared Receiver
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
LOW PIEZO
' motor driver logic to 0 - low all port pins
low portb.0
low portb.1
low portb.3
low portb.4
pause 500
' *** Clear Serial LCD ***
DEBUG Ins,clr : PAUSE 30
' *** Setup Line 1 and Line 2 ***
DEBUG Ins,LINE1,"Left Mid Right" : PAUSE 30
DEBUG ins,LINE2," " : PAUSE 30
TRISA = %11111111 ' All PORTA Inputs
TRISB = %00000000 ' All PORTB output
ANSEL = %00000111 ' Set 0,1,2 to A/D, A/D clock = Frc
RESULT VAR BYTE[3] ' 3-BYTE ARRAY STORAGE FOR 3 A/D CONVERSIONS
C VAR BYTE ' ADC CHANNEL NUMBER BYTE VARIABLE
MAIN:
FOR C = 0 TO 2 ' 3-CHANNEL COUNTER LOOP
ADCIN C, RESULT[C] ' Read all 3 channels
PAUSE 10 ' Pause 10mS
NEXT C
PAUSE 250 ' PAUSE 250mS
DEBUG ins,LINE2,dec RESULT[0]," "
debug ins,line2+6,dec RESULT[1]," "
debug ins,line2+11,dec result[2]," "
GOTO MAIN ' DO IT AGAIN
END ' END PROGRAM
Bookmarks