+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Location
    Georgia, USA
    Posts
    18

    Default Can PortA of PIC16F877 be used for LCD, by using DT's ALLDIGITAL.pbp ?

    PIC16F877
    PBP Ver 2.6C

    I can't get port A to work with LCD.
    Port C and D work fine.

    I'm sure I missed somthing just can't seem to find it.

    Thanks

    Ld

    Code Trying:

    INCLUDE "ALLDIGITAL.pbp" 'Darrel Taylor's Include
    ' DEFINE SHOWDIGITAL 1
    '-------------------------------------------------------
    DEFINE OSC 10 ' We're using a 10MHz oscillator
    DEFINE HSER_RCSTA 90h ' enable serial port,
    define HSER_TXSTA 24h ' enable transmit,
    define HSER_BAUD 9600 ' set baudrate to 9600
    DEFINE HSER_CLOERR 1 ' automatic clear overrun error
    'Define LCD
    DEFINE LCD_DREG PORTA 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTA 'LCD register select port
    DEFINE LCD_RSBIT 5 'LCD register select bit
    DEFINE LCD_EREG PORTA 'LCD enable port
    DEFINE LCD_EBIT 4 'LCD enable bit
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    DEFINE LCD_COMMANDUS 2000 '2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    TempB VAR BYTE
    BUSdata VAR BYTE


    '================================================= =================


    PAUSE 3500

    Main:
    GOSUB LCD_INIT ' Do manual LCD Initialization
    Lloop:
    Pause 1000 ' Wait .5 second
    Lcdout $FE, 1 ' Clear LCD screen
    Lcdout "Hello" ' Display Hello
    Pause 1000 ' Wait .5 second
    Lcdout $FE, $C0
    Lcdout "World"
    Pause 1000 ' Wait .5 second
    Goto Lloop ' Do it forever

    ;---- Manual LCD Initialization -------------------------------------
    LCD_INIT:
    @ MOVE?CT 0, LCD_RSREG,LCD_RSBIT ; Start with RS LOW
    @ MOVE?CT 0, LCD_RSREG+80h,LCD_RSBIT ; RS is OUTPUT
    @ MOVE?CT 0, LCD_EREG,LCD_EBIT ; Start with Enable LOW
    @ MOVE?CT 0, LCD_EREG+80h,LCD_EBIT ; Enable is OUTPUT
    @ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT ; Data Bus is OUTPUT
    @ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT +1
    @ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT +2
    @ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT +3
    PAUSE 1000
    BUSdata = 3
    GOSUB Send4Bit : pause 8 ; FunctionSet 4 times
    GOSUB Send4Bit : pauseUS 200
    GOSUB Send4Bit : pauseUS 200
    GOSUB Send4Bit : pauseUS 200
    BUSdata = 2 : GOSUB Send4Bit ; 4-bit mode
    BUSdata = 2 : GOSUB Send4Bit ; 2-line, 5x7
    BUSdata = 8 : GOSUB Send4Bit
    BUSdata = 0 : GOSUB Send4Bit ; Display OFF
    BUSdata = 8 : GOSUB Send4Bit
    BUSdata = 0 : GOSUB Send4Bit ; Display Clear
    BUSdata = 1 : GOSUB Send4Bit
    PAUSE 3
    BUSdata = 0 : GOSUB Send4Bit ; Entry Mode Set
    BUSdata = 6 : GOSUB Send4Bit
    PAUSE 3
    BUSdata = 0 : GOSUB Send4Bit ; Display ON
    BUSdata = $C : GOSUB Send4Bit
    @ MOVE?CT 1, LCDINITFLAG ; Tell PBP LCD is already Initialized
    return

    Send4Bit:
    @ MOVE?CT 1, LCD_EREG,LCD_EBIT ; Enable LCD
    @ MOVE?BB LCD_DREG, _TempB ; Put Data on the Bus R-M-W
    @ if LCD_DBIT == 0 ; Bus starts at 0
    TEMPB = (TEMPB & $F0) | BUSdata
    @ else ; Bus starts at 4
    TEMPB = (TEMPB & $0F) | (BUSdata << 4)
    @ endif
    @ MOVE?BB _TempB, LCD_DREG
    PAUSEUS 25 ; Keep enabled extra long
    @ MOVE?CT 0, LCD_EREG,LCD_EBIT ; Disable LCD
    Pauseus 50
    return
    ;---------- END LCD_INIT --------------------------------------------

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: Can PortA of PIC16F877 be used for LCD, by using DT's ALLDIGITAL.pbp ?

    RA4 is an open drain output.
    You'll need a pull-up resistor on that pin.
    DT

  3. #3
    Join Date
    Dec 2012
    Location
    Georgia, USA
    Posts
    18

    Default Re: Can PortA of PIC16F877 be used for LCD, by using DT's ALLDIGITAL.pbp ?

    Thank You Darrel !!,

    I put a 10K pullup,
    Works Great now.

    Thanks
    Ld

Similar Threads

  1. Can't seem to add AllDigital to the include files
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th November 2009, 05:21
  2. PIC16F877 PORTA Input Issue
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th December 2005, 21:33
  3. LCD Data on portA and portB
    By EDWARD in forum mel PIC BASIC
    Replies: 31
    Last Post: - 22nd July 2005, 14:27
  4. Lcd On Porta And Portb
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th May 2005, 05:53
  5. 4-line LCD Help - using PortA instead of B
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 31st March 2005, 03:14

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