LCD Display


Closed Thread
Results 1 to 2 of 2

Thread: LCD Display

  1. #1
    lambert's Avatar
    lambert Guest

    Default LCD Display

    Hi guys,

    I'm new to pic-chip programming and am having trouble getting an MCC162b3 lcd display to work. I am using a pic16f873a. Below is the code I am using, which is basically the picBasic sample program, but I changed LCD_DREG to PORTC because I need the ADCs on portA.

    I saw in another forum for another pic-chip to set ANSEL=0. I'm not sure what ANSEL is, but it causes a compilation error for me.

    Thanks in advance.
    L.


    DEFINE LCD_DREG PORTC ' Set LCD Data port
    DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTA ' Set LCD Register Select port
    DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 3 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' 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

    define OSC 20
    TRISC = %00000000
    TRISA = %000011 'A.0 and A.1 for ADC input
    TRISB = %00000000


    '
    ' LCD is connected as follows:
    ' LCD PIC
    ' DB4 PortC.0
    ' DB5 PortC.1
    ' DB6 PortC.2
    ' DB7 PortC.3
    ' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
    ' E PortB.3
    ' RW Ground
    ' Vdd 5 volts
    ' Vss Ground
    ' Vo 20K potentiometer (or ground)
    ' DB0-3 No connect

    Pause 5000 ' Wait for LCD to startup

    loopy:
    Lcdout $FE, 1 ' Clear LCD screen
    Lcdout "Hello" ' Display Hello
    Pause 2000 ' Wait .5 second

    Lcdout $FE, 1 ' Clear LCD screen
    Lcdout "World"
    Pause 2000 ' Wait .5 second

    Goto loopy ' Do it forever

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Lambert,
    Welcome to the forum!
    In MPASM SUITE, in your MICROCHIP directory, exists files named for each PIC supported, in this case named P16F873A.inc .
    Open it in MCS and examine it, there you will find every register available. No ANSEL there, that's why it errors.
    look at the list below for suggested changes.

    TRISA = %00000011 'Set all bits even if port has access to only some
    ' Disable comparators !
    ' Disable analog functions on Ports A, C, capture compare , ADCON. . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. assembly in Pic
    By lerameur in forum Off Topic
    Replies: 11
    Last Post: - 1st May 2008, 21:06
  2. LCD display not working properly
    By dilpkan in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd February 2008, 08:43
  3. Replies: 14
    Last Post: - 26th September 2007, 06:41
  4. LCD Display not working - PIC heating...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 24th September 2006, 08:35
  5. A/D display result on LCD
    By winsthon in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 10th January 2004, 11:09

Members who have read this thread : 1

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

Posting Permissions

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