Oops, thats a mistake from when I was cleaning it up to post, the revised code is below XD
The only issue that remains is that my timing is not precise enough and I'm losing a lot of the button press bits. I think the only solution is purchasing a crystal as the internal oscillator is not accurate enough.Code:Include "modedefs.bas" OSCCON = %01110000 ' INTRC = 8MHz DEFINE OSC 8 DEFINE LCD_DREG PORTB ' Set LCD Data port DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus i.e, PortD.4-PORTD.7 DEFINE LCD_RSREG PORTD ' Set LCD Register Select port DEFINE LCD_RSBIT 2 ' Set LCD Register Select bit i.e, PORTC.5 DEFINE LCD_EREG PORTD ' Set LCD Enable port DEFINE LCD_EBIT 4 ' Set LCD Enable bit i.e, PORTE.4 DEFINE LCD_BITS 8 ' Set LCD bus size ot 4 bit Upper Nibble (4 or 8 bits) DEFINE LCD_LINES 4 ' Set number of lines on LCD to 4 Lines DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us DEFINE LCD_DATAUS 50 ' dSet data delay time in us DEFINE LCD_RWREG PORTD DEFINE LCD_RWBIT 3 theoutput var Word ANSEL = 0 PAUSE 1000 ' Wait a second OUTPUT PORTC.1 ' configure input/output pins OUTPUT PORTC.0 INPUT PORTC.2 LOW PORTC.1 ' Initialize LATCH LOW PORTC.0 ' Initialize CLK Loop: ' Main loop PULSOUT PORTC.1, 10 ' Latch the data SHIFTIN PORTC.2, PORTC.0, MSBPRE,[theoutput \16] ' Shift in socket 1 data LCDOUT $FE, 1, BIN16 theoutput ' Display values pause 50 GOTO Loop END ' Repeat main loop




Bookmarks