Tut 16 : LCD Custom Characters

Most of the alpha numeric LCD like 16x2 character has ability to generate few custom characters. Custom characters on any 16x2 LCD provides the functionality of CGRAM (Character Generator RAM) where you can create your own characters for display. The codes for custom character generation using PIC16F877 microcontroller can be created using any custom character generator available in the internet. The custom character generation using  PIC16F877 is in 8bit mode. 
 
Custom characters on LCD  

Battery character on LCD 
 
We can program 8 custom characters when we are using 5x8 font in the LCD settings and we can program 4 custom characters when we are using 5x10 font in the LCD settings. The binary coding in the custom charactor generator can be written in HEX form as in PBP program below.
Custom character generator
 
PBP Program
'program to display some characters on LCD
 
DEFINE OSC 20
    @ device hs_osc

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
 
TRISB = 0
TRISD = 0

LCDOUT  $FE,$40,$00,$0A,$0A,$00,$11,$0E,$00,$00  ' Cust Char #0: happy smiley 
LCDOUT  $FE,$48,$0E,$15,$1B,$19,$1B,$15,$0E,$00  ' Cust Char #1: copyright
LCDOUT  $FE,$50,$0E,$0E,$1F,$0E,$04,$00,$1F,$00  ' Cust Char #2: press 

Pause 500
LCDOut $FE,1
 
Loop:
LCDOut $FE,$80+0,0
Pause 1000
LCDOut $FE,$80+1,1
Pause 1000
LCDOut $FE,$80+2,2
Pause 1000
GoTo loop
 

No comments:

Post a Comment