HI all i am have a challenging time with my code here.
am using 5 if -then statements to read the ports status in digital. My problem is i can read each port on its own but not the whole lot grouped together.
Pic 16f88 int osc 8MHz
PBP 2.47
Melabs U2 programmer
my code is as follows
OSCCON = %01111000 ' INTRC = 8MHz
'OSCON = %01101000 4 MHz
TRISA = %11111111
ANSEL = 0 'DISABLE ALL ADC
CMCON = 7 'DISABLE ALL ANALOG COMPARATOR
WHILE OSCCON.2=0:WEND 'STABILISE THE CLOCK
ADCON1 = 1
DEFINE OSC 8
PAUSE 1000
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4 '4,5,6,7
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
pause 1000
lcdout $fe, 1
TRISA.0=1 'INPUT PIN PUMP ON OFF
TRISA.1=1 'INPUT PIN DALLAS 1 WIRE DS18S20
TRISA.2=1 'INPUT PIN WATER SENSOR
TRISA.6=1 'INPUT PIN TEMP BUTTON DOWN
TRISA.7=1 'INPUT PIN TEMP BUTTON UP
TRISA.3=0 'OUTPUT PIN na
TRISA.4=0 'OUTPUT PIN na
TRISA.5=0 'OUTPUT PIN na
TRISB.0=0 'OUTPUT PIN IGNITION
TRISB.1=0 'OUTPUT PIN GAS VALVE
low PORTB.0
low PORTB.1
MAIN:
lcdout $fe, $80+0, "PUMP off GAS off"
lcdout $fe, $c0+8, "WATER"
if PORTA.2 = 1 then GOTO waterok
if PORTA.2 = 0 then GOTO waterbad
if PORTA.6 = 1 then GOTO tempdown
if PORTA.7 = 1 then GOTO tempup
PAUSE 500
GOTO MAIN
waterok:
lcdout $fe, $c0+13, " OK"
goto main
waterbad:
lcdout $fe, $c0+13, "BAD"
goto main
tempdown:
lcdout $fe, $80+0, "TEMP DOWN "
goto main
tempup:
lcdout $fe, $80+0, "TEMP UP "
goto main
END
why cant i get this to work. it looks logical.
oh b4 i forget the MCLR is set as an input and the osc is set as INTRC with the u2 programmer
Thanks
crazy cooter
Bookmarks