Well i ran out of memory at around 700 lines
Now the code i have at the moment isn't that far but im getting close!
so i'm after any advice on the code i have on ways of doing the same thing without using as much memory!
Would using tables on menus help reduce space as i still have ALOT of coding to do!
I know the code is quite fragmented and not well ordered but I had planned to rewrite it its just me making a beta of it at the moment!
cheers!
Code:' ' Olympic Timer ' ============= ' Melanie Newman ' 05/Aug/2004 ' Modified by Chris Hammersley ' For Spec-ops.nl ' Oct 2008 ' Topical Program demonstrates use of Interrupt ' Driven Background TIMER, to time events down to ' one one-hundredth of a Second (1/100 Sec). ' ' Bonus CALIBRATION Feature allows simple adjustments ' in 360mS steps per hour. This calibration adjustment ' range is limited to +/- 36 seconds per Hour. ' ' This program is for 4MHz clock (1uS Timer Ticks). 'Original programe includes a calibratable stop clock counting upwards. 'MODIFICATIONS '------------- 'V1.1 23rd october 2008 'Working menu selecting game length with 2 presets and a customisable 'Count down clock. 'Programe knows when time is up and goto new instructions. ' PIC Defines ' ' 'V1.2 Ongoing 'GAME TYPES MENU INCLUDED 'INCLUDED THE CODING FOR BOTH COUNT-DOWN AND COUNT-UP CLOCKS ' 'V1.3 FUTURE 'INCLUDE RF OPERATIONS ' ' =========== ' ' Change these defines to suit your chosen PIC ' '@ DEVICE pic16F876a, WDT_ON ' Watchdog Timer '@ DEVICE pic16F876a, PWRT_ON ' Power-On Timer '@ DEVICE pic16F876a, BOD_ON ' Brown-Out Detect '@ DEVICE pic16F876a, LVP_OFF ' Low-Voltage Programming '@ DEVICE pic16F876a, CPD_OFF ' Data Memory Code Protect '@ DEVICE pic16F876a, PROTECT_OFF ' Program Code Protection '@ DEVICE pic16F876a, WRT_OFF ' Flash Memory Word Enable ' ' 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 ' ' Hold the RESET Button pressed for at least FIVE seconds ' to jump into CALIBRATION Mode ' ' 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 TIMER 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 ' ------------------ TMR1CalMax con 100 ' Maximum adjustment (+/-100uS per 10mS interrupt) TMR1Preset con $D910 ' 10mS Timer Reload value, offset by 20uS ' to allow for TMR1 Setting Calculations ' ' Start Program ' ============= ' ' Initialise Processor ' -------------------- TRISA=%00000000 TRISB=%00000000 TRISC=%00011111 ADCON0=%11000000 ADCON1=%00000111 OPTION_REG.7=0 ' Enable Pull-Up's RunningFlag=0 ' Disable actual Interrupt Time-Keeping Pause 1000 ' Pause for LCD to initialise ' ' Silly Intro Banner just for Fun ' ------------------------------- LCDOut $FE,1 ' Clear LCD BannerOffset=2:Gosub DisplayBanner Pause 2000 For CounterA=0 to 33 BannerOffset=2+CounterA Gosub DisplayBanner Pause 350 'pause between change of characters Next CounterA Pause 4000 '---------------- 'Menu and Presets '---------------- ' 'MAIN MENU '--------- MAINMENU: PAUSE 1000 MAINMENUA: LCDOUT $FE, 1, " SELECT MENU" LCDOut $FE,$C0,"COUNTDOWN" PAUSE 100 IF BUTSTART=0 THEN GOTO MENUA ENDIF IF BUTUP=0 THEN GOTO MAINMENUB ENDIF GOTO MAINMENUA MAINMENUB: LCDOUT $FE, 1, " SELECT MENU:" LCDOut $FE,$C0," COUNT UP" PAUSE 100 IF BUTDWN=0 THEN GOTO MAINMENU ENDIF IF BUTSTART=0 THEN TIMER=1 PAUSE 20 IF BUTSTART=0 THEN GOTO BEGINNING ENDIF ENDIF PAUSE 50 GOTO MAINMENUB





Bookmarks