This page created with Cool Page.  Click to get your own FREE copy of Cool Page!
Making PIC Instruments and Controllers.
Ancillary information
06 Jan '09

Chapter 9  Liquid Crystal Displays.  (LCDs)


Program 9.1 For a PIC 16F84A (Program to simulate back pack
[by microEngineering Labs])
; PicBasic Pro program to simulate an LCD Backpack
; 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 ;
;
CHAR VAR BYTE ; Storage for serial character
MODE VAR BYTE ; Storage for serial mode
RCV VAR PORTB.7 ; Serial receive pin
BAUD VAR PORTA.0 ; Baud rate pin - 0 = 2400, 1 = 9600
STATE VAR PORTA.1 ; Inverted or true serial data - 1 = true
;
ADCON1 = %00000111 ; Set PORTA and PORTE to digital
LOW PORTE.2 ; LCD R/W line low (W)
PAUSE 500 ; Wait for LCD to startup
;
MODE = 0 ; Set mode
IF (BAUD == 1) THEN ;
MODE = 2 ; Set baud rate
ENDIF ;
;
IF (STATE == 0) THEN ;
MODE = MODE + 4 ; Set inverted or true
ENDIF ;
;
LCDOUT $FE, 1 ; Initialize and clear display
;
LOOP: ;
SERIN RCV, MODE, CHAR ; Get a char from serial input
LCDOUT CHAR ; Send char to display
GOTO LOOP ; Do it all over again
END ; end program









Program listings are listed in detail so you can see the code