Using a faster crystal may help but your biggest problems are,
You are writing (and reading back) to EEPROM and writing to the LCD in your interrupt service routine. Both these things have a long wait before they finish. I'm assuming your interrupt start with the "on interrupt" instruction and ends at the resume instruction.
If I had to guess what your code would be, it would be something like,
Code:
Dim interrupt_count As Byte
Dim timeroffset As Word
Dim tmroffset As Word
Dim count1 As Word 'RB0 interrupt count
Dim countcopy As Word
TRISA = %0000000
TRISC = 0
OPTION_REG.6 = 1 'RB0/INT edge triggered (Rising)
OPTION_REG.7 = 0 ' PORTB pull up enabled by individual port latch value
INTCON.INTE = 0 'External interrupt for RB0 disable!
INTCON.7 = 1 'Global interrupt enabled!
Symbol t1ck0 = T1CON.4 ' Timer1 Input Clock Prescale Select bits
Symbol t1ck1 = T1CON.5 ' Timer1 Input Clock Prescale Select bits
Symbol sensor = PORTD.0 'sensor
'WaitMs 3000
Define LCD_LINES = 2
Define LCD_CHARS = 8
Define LCD_BITS = 4 'allowed values are 4 and 8 - the number of data interface lines
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 '0 or 4 for 4-bit interface, ignored for 8-bit interface
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 1
Define LCD_EREG = PORTB
Define LCD_EBIT = 3
Define LCD_RWREG = PORTB 'set to 0 if not used, 0 is default
Define LCD_RWBIT = 2 'set to 0 if not used, 0 is default
Lcdinit
WaitMs 2 'wait For lcd To start
Lcdcmdout 0x0e 'Underline cursor on
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "RPM" 'Clear LCD display
Lcdcmdout LcdLine2Home
Lcdout "Ver1.0"
timeroffset = 15535 ' interrput occurs every 50 ms(0.05sec)
t1ck0 = 0 'prescaler 1:1 selected
t1ck1 = 0
PIE1.0 = 1 'enable TMR1 interupts
INTCON.6 = 1 'enable all unmasked interrupts
INTCON.7 = 1 'enable Global interrupts
PIR1.0 = 0 'reset interupt flag
T1CON.0 = 0 'stop the timer
TMR1H = timeroffset.HB 'timersethigh 'load a start up value into the timer
TMR1L = timeroffset.LB 'timersetlow
T1CON.0 = 1 'start the timer
INTCON.INTE = 1 'External interrupt for RB0 enable!
main:
If countcopy=0 then goto main
gosub menu1
countcopy=0
goto main
On Interrupt
If INTCON.1 = 1 Then 'RB0 External interrupt count!
count1 = count1 + 1
INTCON.INTF = 0 'RB0 External Interrupt flag bit cleared!
Endif
If PIR1.0 = 1 Then 'TMR1F - Timer 1 overflow interrupt flag bit ;1=overflow
T1CON.0 = 0 'stop the timer
TMR1H = timeroffset.HB 'timersethigh 'load a start up value into the timer
TMR1L = timeroffset.LB 'timersetlow
PIR1.0 = 0 'reset TMR1 interupt flag
interrupt_count = interrupt_count + 1 'timer 1 interrupt count
If interrupt_count = 20 Then '1 sec elapsed!
interrupt_count = 0
Gosub menu1
countcopy=count1
count1 = 0
T1CON.0 = 1 'start the timer
Endif
Endif
Resume 'return back to where set timer was called
menu1:
Lcdcmdout LcdClear
Lcdout "RPM"
Lcdcmdout 0xc0
Lcdout "RPM:" 'count
Gosub update1
Return
update1:
Lcdcmdout LcdLine2Pos(5)
countcopy = countcopy * 5 '12 slot used (1 minute Total count)
Lcdout #countcopy ' RPM
Return
Mike.