Dave Thank for the pointer
i have manage to get just RB0 and RB2 working but i do get strange results for RB1
when i press the button connected to Rb1, the the message Rb0 pressed displayed before displaying Rb1 pressed.
Could someone please help me with this
DEFINE LOADER_USED 1 ' uses a bootloader
INCLUDE "Modedefs.Bas"
' ** Setup Crystal Frequency in mHz **
DEFINE OSC 20 ' Set Xtal Frequency
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 0
DEFINE LCD_RWREG PORTD ' PORTD for R/w bit
DEFINE LCD_RWBIT 2 ' PORTD-1 for LCD's R/W line
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000' Command Delay (uS)
DEFINE LCD_DATAUS 50 ' Data Delay (uS)
I CON 254 ' Control Byte
Clr CON 1 ' Clear the display
Line1 CON 128 ' Point to beginning of line 1
Line2 CON 192 ' Point to beginning of line 2
' ** Define the bits within the ADCON1 register **
index VAR BYTE
R0 VAR BYTE
R1 VAR BYTE
R2 VAR BYTE
TRISA=%00111111
TRISB=%00100111
TRISC=%10100110
TRISD=%00001000
TRISE.0=1
TRISE.1=1
TRISE.2=1
INTCON2.7=0 'Enable portB pullups
INTCON2.6=0 '%Interupt on falling edge
Main:
Pause 1000 ' delay for lcd
Loop:
'==== ================================================== ========================
LCDOut I,Clr
LCDOut I,Line1,"Power on"
For index =1 TO 500
Pause 1
Next index
ON INTERRUPT GoTo myint1 ' Define interrupt handler
INTCON=%10010000 ' Enable RB0 interupt
'The RB0 interupts works ok but RB1 & RB2 don't
'Dummy code
'kkkkkkkkkkkkkkkkkkk
ON INTERRUPT GoTo myint2 ' Define interrupt handler
INTCON2.4=0: INTCON2.5=0 ' Enable RB2 interupt
INTCON3.7=1:INTCON3.6=1
INTCON3.4=0:INTCON3.3=1
ON INTERRUPT GoTo myint3 ' Define interrupt handler
INTCON2.4=0: INTCON2.5=0 ' Enable RB2 interupt
INTCON3.7=1:INTCON3.6=1
INTCON3.4=1:INTCON3.3=0
GoTo Loop
End
' RB0 Interrupt handler
' ===========================
myint1:
Disable ' No interrupts past this point
LCDOut I,Clr
LCDOut I,Line1,"RB0 Pressed"
For R0 = 1 TO 500 ' allow user to see
Pause 1
Next
INTCON.1 = 0 ' Clear interrupt flag
Resume ' Return to main program
Enable
' RB1 Interrupt handler
' ===========================
myint2:
Disable ' No interrupts past this point
LCDOut I,Clr
LCDOut I,Line1,"RB1 Pressed"
For R1 = 1 TO 500 ' allow user to see
Pause 1
Next
INTCON3.0 = 0 ' Clear interrupt flag
INTCON3.1 = 0
Resume ' Return to main program
Enable
' RB2 Interrupt handler
' ===========================
myint3:
Disable ' No interrupts past this point
LCDOut I,Clr
LCDOut I,Line1,"RB2 Pressed"
For R2 = 1 TO 500 ' allow user to see
Pause 1
Next
INTCON3.0 = 0
INTCON3.1 = 0 ' Clear interrupt flag
Resume ' Return to main program
Enable
Itm
Bookmarks