Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Header file and defines for Serial LCD Controller
;-----[ Includes ]---------------------------------------------------------
INCLUDE "16F628A.pbp"
;-----[ Defines ]----------------------------------------------------------
;Define oscillator speed in Mhz
DEFINe OSC 20
;Define which port is connected to the LCD Data pins D4 - D7
DEFINE LCD_DREG PORTB
;Define starting Data bit on port (0 for 8-bit or 4 for 4-bit port)
DEFINE LCD_DBIT 4
;Define LCD Bus size (4-bit or 8-bit)
DEFINE LCD_BITS 4
;Define LCD Register Select (RS) port
DEFINE LCD_RSREG PORTA
;Define LCD Register Select (RS) bit
DEFINE LCD_RSBIT 0
;Define LCD Read/Write (RW) Port
DEFINE LCD_RWREG PORTA
;Define LCD Read/Write (RW) bit
DEFINE LCD_RWBIT 2
;Define LCD Enable (E) port
DEFINE LCD_EREG PORTA
;Define LCD Enable (E) bit
DEFINE LCD_EBIT 1
;Define number of lines on LCD
DEFINE LCD_LINES 4
;Define LCD command delay time
DEFINE LCD_COMMANDUS 2000
;Define LCD data delay time
DEFINE LCD_DATAUS 50
;Enable serial port & continuous receive
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
;Clear overflow automatically
DEFINE HSER_CLROERR 1
;Turn off PORTA comparators
CMCON = 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment