Hi there, im currently trying to create a menu on a LCD display which im having some troubles with. Ill post m code further down but the code seems to be running straight through and then freezing with "game length" on the top and the minutes on the bottom. I guess ive missed somthing but for all the time ive spent looking i can't see the problem!
Cheers
Also i forgot to mention it is possible to change one of the values on the timer if you rapidly press the button as it turns on then after this i get no responce!
Code:
' Hardware Defines
' ================
CMCON=%00000111
CVRCON=%00000000
'
' LCD Display
' -----------
' Adjust these to suit your chosen LCD pinout
'
DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 4 'Define first pin of portb connected to LCD DB4
DEFINE LCD_RSREG PORTB 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 3 'Define Portb pin used for RS connection
DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD
DEFINE LCD_EBIT 0 'Define PortB pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.
' Control Buttons/Lines
' ---------------------
ButStart var Portc.0 ' Take this pin low momentarily to START timing
ButStop var Portc.1 ' Take this pin low momentarily to STOP timing
ButReset var Portc.2 ' Take this pin low momentarily to RESET clock
Butup var portc.3 ' Take this pin low momentarily to increase clock time
Butdwn var portc.4 ' Take this pin low momentarily to decrease clock time
'
' Software Defines
' ----------------
BannerOffset var BYTE ' Variable holding start address of Banner Display
CounterA var BYTE ' Just a Counter
CounterB var BYTE ' Just a Counter
CounterC var BYTE
DataA var BYTE
Hours var BYTE
Hundredths var BYTE
Minutes var BYTE
OverflowError var BIT
RunningFlag var BIT
Seconds var BYTE
SetupTimeOut var WORD ' Timeout counter for Calibration/Set-Up Mode
TMR1Cal var BYTE ' Calibration Value
IHOURS VAR BYTE
IMINUTES VAR BYTE
TMR1CalAR var Byte ' Calibration 0=ADVANCE, 1=RETARD
TMR1RunOn var WORD ' variable holding TMR1 Run-On value
'
' EEPROM Presets
' --------------
'Data @0,0 ' Advance/Retard Indicator
'Data 0 ' Calibration Value
'Data "Spec-ops.nl Tactical Game Aid - Enter Game Length"
'
' Software Constants
' ------------------
' Initialise Processor
' --------------------
TRISA=%00000000
TRISB=%00000000
TRISC=%00011111
ADCON0=%11000000
ADCON1=%00000111
' INITIAL Time Setup
'----------------------------
start:
IHOURS=0
IMINUTES=3
HOURSI:
If Butup=0 then
IHOURS=IHOURS+1
IF BUTDWN=0 THEN
IHOURS=IHOURS-1
IF BUTSTART=0 THEN
GOTO MINSI
ENDIF
ENDIF
ENDIF
GOSUB TIMESETUP
MINSI:
If Butup=0 then
IMINUTES=IMINUTES+1
IF BUTDWN=0 THEN
IMINUTES=IMINUTES-1
IF BUTSTART=0 THEN
GOTO CONTINUE
IF BUTRESET=0 THEN
GOTO HOURSI
ENDIF
ENDIF
ENDIF
ENDIF
GOSUB TIMESETUP
timesetup:
LCDOUT $FE, 1, "GAME LENGTH"
LCDOut $FE,$C0,DEC2 IHours,":",DEC2 IMinutes,":00.00"
PAUSE 200
REturn
'butup and butdwn
Continue:
LCDOUT $FE, 1, "Settings Saved"
pause 1000
goto continue
end
Bookmarks