I just tested you code and every time PORTB.0 is connected to 0 volts(ground) the LED blinks and the LCD counts.
Here is what I have with a couple small changes. Look at comments.
Code:DEFINE OSC 20 Define LCD_DREG PORTD Define LCD_DBIT 4 Define LCD_RSREG PORTD Define LCD_RSBIT 2 Define LCD_EREG PORTD Define LCD_EBIT 3 DEFINE LCD_LINES 2 'Number lines on LCD TRISB.0 = 1 led var PORTB.5 'CHANGED BECAUSE ICSP counter var byte OPTION_REG = %01111111 'Enable portb pullups and 'rising edge on B0 interrupt On interrupt goto myint 'Define interrupt handler INTCON = %10010000 'Enable INTE interrupt counter = 0 '**** Main Loop *** loop: lcdout $fe,1 'CLEAR SCREEN lcdout "Count=",# counter 'display count value pause 50 'TIME TO DISPLAY high led 'turn led on goto loop 'Do it forever '*****Interrupt Handler ***** Disable 'No interrupts pass this point myint: low led 'if we get here turn led off Pause 300 'wait .3 seconds counter = counter + 1 INTCON.1 = 0 'clear interrupt flag resume 'return to main program enable end





Bookmarks