' Name : BPX1934X.pbp ' Compiler : PICBASIC PRO Compiler 2.6 ' Assembler : MPASM ' Target PIC : 40-pin 16F1934 or similar ' Hardware : LAB-X1 Experimenter Board ' Oscillator : 4MHz external crystal ' Keywords : LCDOUT, HSERIN ' Description : PICBASIC PRO program to simulate an LCD Serial Backpack. ' Serial data received on the USART is displayed on the LAB-X1 LCD. ' ' Define LCD registers and bits Define LCD_DREG PORTD Define LCD_DBIT 4 Define LCD_RSREG PORTE Define LCD_RSBIT 0 Define LCD_EREG PORTE Define LCD_EBIT 1 Define HSER_BAUD 9600 Define HSER_CLROERR 1 ' Automatically clear over-run errors Define HSER_RCSTA 90h ' Enable USART receive Define HSER_TXSTA 24h ' TXSTA=%00100100. TX enable, BRGH=1 for high-speed char Var Byte ' Storage for serial character Gosub Init ' Hardware initialization routine ClrLCD: Lcdout $fe, 1 ' Initialize and clear display Mainloop: Hserin [char] ' Get a char from serial input If char="~" Then ClrLCD ' Send the ~ character to clear LCD display Lcdout char ' Send char to display Goto Mainloop ' Do it all over again Init: ANSELA = 0 ' porta all digital ANSELB = 0 ' portb all digital ANSELD = 0 ' portd all digital ANSELE = 0 ' porte all digital OPTION_REG.7 = 1 ' Disable PORTB pullups TRISD = 0 ' PORTD all outputs Pause 100 ' Wait for LCD to start Return ' Return to caller End