Code:
'initialize device
@ device pic16f747, INTRC_OSC_NOCLKOUT, MCLR_OFF
OSCCON = $60 'internal 4mHz oscillator
define lcd_ereg porte
define lcd_ebit 0
'Initialize ports
TRISA.6 = 1
TRISA.7 = 1
TRISB = $F0
TRISC = $FF 'set all PORTC pins to inputs
TRISD = 0
PORTD = 0
'initialize variables
Index var byte
x var byte
switches var byte
Symbol START_button = PORTB.6
Symbol STOP_button = PORTB.5
Symbol CLEAR_button = PORTB.7
Ticks var byte
Minute var byte
Second var byte
Disp var byte
Delay var byte
'Initialize LCD
Pause 1000 'pause 1 sec to let LCD initialize
LCDOUT $FE,1," Firing Panel V.2"
pause 2000
SETUP:
LCDOUT $FE,1,"Firing Mode:"
LCDOUT $FE,150,"Panel Selected:"
LCDOUT $FE,192,"Wireless Bank:"
lcdout $FE,214,"Time:"
Minute = 0
Second = 0
Ticks = 0
Disp = 1
OPTION_REG = $05
ON INTERRUPT GOTO ISR
LOOP:
Index = PORTc & $0F 'Read DIP switch AND mask lsb
LOOKUP2 Index,[ 1, 2, 3, 4, 5,06,07,08,09,10,11,12,13,14,15,16],x
LCDOUT $FE,166, #x
DISPLAY:
IF Index = 0 THEN 'Panel 1 selected
PORTD = $06 'display 1 on LED display
endif
IF Index = 1 THEN
PORTD = $5B '...
endif
IF Index = 2 THEN
PORTD = $4F
endif
IF Index = 3 THEN
PORTD = $66
endif
IF Index = 4 THEN
PORTD = $6D
endif
IF Index = 5 THEN
PORTD = $7C
endif
IF Index = 6 THEN
PORTD = $07
endif
IF Index = 7 THEN
PORTD = $7F
endif
IF Index = 8 THEN
PORTD = $67
endif
IF Index = 9 THEN
PORTD = $BF
endif
IF Index = 10 THEN
PORTD = $86
endif
IF Index = 11 THEN
PORTD = $BB
endif
IF Index = 12 THEN
PORTD = $CF
endif
IF Index = 13 THEN
PORTD = $E6
endif
IF Index = 14 THEN
PORTD = $ED
endif
IF Index = 15 THEN
PORTD = $FC
endif
LEDS:
switches = (PORTC >> 4) & $0F
if switches > 0 then
goto LEDSLCD:
else
goto BLANK:
endif
LEDSLCD:
IF switches = %00000001 THEN
lcdout $FE,207," J "
portB=1
endif
IF switches = %00000010 THEN
lcdout $FE,207," K "
portB=2
endif
IF switches = %00000100 THEN
lcdout $FE,207," L "
portb=4
endif
IF switches = %00001000 THEN
lcdout $FE,207," M "
portb=8
endif
BLANK:
IF PORTA.6 = 1 THEN
portb = 0
lcdout $FE,207,"None "
endif
SAFETY:
IF PORTA.7 = 1 THEN
lcdout $FE,141,"ARMED"
ELSE
lcdout $FE,141,"SAFE "
endif
RESET:
IF portb.4 = 1 THEN
goto setup:
endif
TIMER:
IF START_button = 1 THEN
TMR0 = 0
INTCON = $a0
Disp = 1
endif
IF STOP_button = 1 THEN
INTCON = 0
Disp = 1
endif
IF CLEAR_button = 1 THEN
INTCON = 0
Minute = 0
Second = 0
Ticks = 0
Disp = 1
endif 'Line 171
IF Disp = 1 THEN
lcdout $FE,220
lcdout DEC2 Minute, ":",DEC2 Second
Disp = 0
endif
GOTO Loop:
DISABLE 'Line 180
ISR:
Ticks = Ticks + 1
IF Ticks < 61 THEN NoUpdate
Ticks = 0
Second = Second + 1
IF Second = 60 THEN
Second = 0
Minute = Minute + 1
IF Minute = 60 THEN
Minute = 0
endif
endif
Disp = 1
NoUpdate:
INTCON.2 = 0
Resume
Enable
End
END
Bookmarks