Trying to use CGRAM of LCD with PIC16F877A


Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Dec 2008
    Location
    Charlottesville, VA
    Posts
    31

    Default Trying to use CGRAM of LCD with PIC16F877A

    All,

    I am trying to find a way to create custom characters using the CGRAM of a 20x4 LCD. I've been trying to browse online and I've only located ASM examples. I can't completely understand ASM so I'd much rather write it in PBP. I have the LCD wired to PORTB of my PIC16F877A MCU. I've listed my define's as shown in the code below.
    Code:
    DEFINE OSC 20               ' Define 20MHz Oscillator
    DEFINE LCD_RSREG PORTB      ' Set LCD Register Select port
    DEFINE LCD_RSBIT 1          ' Set LCD Register Select bit - pin 4 of LCD
    DEFINE LCD_RWREG PORTB      ' Set LCD Read Write port
    DEFINE LCD_RWBIT 2          ' Set LCD Read Write bit - pin 5 of LCD
    DEFINE LCD_EREG PORTB       ' Set LCD Enable port
    DEFINE LCD_EBIT 3           ' Set LCD Enable bit - pin 6 of LCD
    DEFINE LCD_DREG PORTB       ' Set LCD Data port
    DEFINE LCD_DBIT 4           ' Set starting bit (0 or 4) if 4-bit bus
    DEFINE LCD_BITS 4           ' 4-bit LCD data bus - pins 11 - 14 of LCD
    DEFINE LCD_LINES 4          ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2000   ' Set command delay time in us
    DEFINE LCD_DATAUS 50        ' Set data delay time in us
    Now, I have no problem with sending messages to my LCD.

    Code:
    MAIN:
        LCDOUT $FE, 1
        LCDOUT $FE, 2
        LCDOUT $FE, $0C
        LCDOUT "Testing my 20x4"
        LCDOUT $FE, $C0
        LCDOUT "LCD project."
        LCDOUT $FE, $94
        LCDOUT "Built By:"
        LCDOUT $FE, $D4
        LCDOUT "Me"
        PAUSE 3000
        GOTO MAIN
    However, I've designed a "logo", if you will, that I would like to display on the LCD. I know that I want to use the 5x8 dot format but I'm not sure how to do this in PBP. Nor am I certain of how to write to the CGRAM addresses that need to be written to in order to display the characters that I'm trying to create. Can anyone provide an example PBP code to help me with this?

    Thanks in advance....
    Last edited by mcbeasleyjr; - 5th November 2011 at 05:33.

    Morris Beasley
    Manufacturing Test Technician
    B.S. Industrial Technology (2007)

    For more information on our robotics, please visit:
    http://www.ish-electronics.webs.com

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts