Menu

LCD with a 16F676

Help
2009-10-05
2013-05-30
  • David Stephenson

    Using the code below I get a blank screen.
    The LCD will work with a 16F876 in both 4 and 8 bit modes.

    #chip 16F676,4
    #config OSC=INTOSC, MCLRE=OFF, WDT=OFF
    #define LCD_IO 4
    #define LCD_DB4 PORTC.4
    #define LCD_DB5 PORTC.5
    #define LCD_DB6 PORTA.4
    #define LCD_DB7 PORTA.5
    #define LCD_RS PORTC.1
    #define LCD_RW PORTC.2
    #define LCD_Enable PORTC.3
    ADOFF
    main:
    PRINT "Hello World"
    WAIT 1 sec
    CLS
    WAIT 1 sec
    GOTO main

     
  • Nobody/Anonymous

    Oh no!
    The message has come out bizarrely formatted all I did was paste it from "notepad".

     
  • David Stephenson

    I just can't seem to post sensible code. The hashes (#) get removed so all the defines should be #define and the final long line should of course be several separate lines. I should point out the program compiles to ASM and Hex. 

     
  • joe rocci

    joe rocci - 2009-10-05

    Make sure your DB lines are configured as digital ports, otherwise they'll default to analog inputs when attempting to read data. You can eliminate the need to be able to read data back from the LCD by connecting the LCD R/W line to ground and inserting the the following code:
    "#define LCD_NO_RW 1".

    Joe

     
  • joe rocci

    joe rocci - 2009-10-05

    …also

    Make sure your LCD contrast pin is biased properly. If the voltage on it is too low, all you'll see is black squares. It it's too high, you won't see anything at all.

     
  • Nobody/Anonymous

    New Guy here,
    is it possible to set this program for serial output

    serprint (portb.1, "hello world")

    NG

     
  • David Stephenson

    Thanks for the suggestions. Turns out I had done something stupid when wiring up the LCD. It's now working fine, and it does seem sensible to work write only saving a pin for other things.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.