Is this code not initialising the LCD properly?


Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Jan 2010
    Location
    In the Shed
    Posts
    6

    Default Is this code not initialising the LCD properly?

    Hi,

    I have been trying to get a standard 44780 LCD to work but all I get is Lines 1 & 3 lit up with solid blocks, and nothing on Lines 2 & 4. See Photo.



    The PIC is a16F886 and the set-up is all correctly wired and has been proven to work using a HEX file given to me by a friend who programs in ASM. Unfortunately he knows nothing about PicBasic...

    The Code I've tried is;
    Code:
    '*******************************************************************************
    '*                 20 x 4 LCD for Display                                      *
    '*                                                                             *
    '*            LCD connected as follows:                                        *
    '*              LCD         PIC         PWR                                    *
    '*             01 Vss                  Ground                                  *
    '*             02 Vdd                  5 volts                                 *
    '*             03 Vo                   Ground (contrast)                       *
    '*             04 RS      24 PortB.3                                           *
    '*             05 RW                   Ground                                  *
    '*             06 E       23 PortB.2                                           *
    '*             07 DB0                  No connect                              *
    '*             08 DB1                  No connect                              *
    '*             09 DB2                  No connect                              *
    '*             10 DB3                  No connect                              *
    '*             11 DB4     25 PortB.4                                           *
    '*             12 DB5     26 PortB.5                                           *
    '*             13 DB6     27 PortB.6                                           *
    '*             14 DB7     28 PortB.7                                           *
    '*             15 A                    5 volts (backlight)                     *
    '*             16 K                    Ground  (backlight)                     *
    '*                                                                             *
    '*******************************************************************************
    
    ' Defines
    '*******************************************************************************
    
    DEFINE OSC 4                'using a 4 MHz oscillator
    DEFINE LCD_DREG PORTB       'LCD data port 
    DEFINE LCD_DBIT 4           'LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTB      'LCD register select port 
    DEFINE LCD_RSBIT 3          'LCD register select bit 
    DEFINE LCD_EREG PORTB       'LCD enable port 
    DEFINE LCD_EBIT 2           'LCD enable bit 
    DEFINE LCD_RWREG PORTB      'LCD read/write port (Not Used This Time)
    DEFINE LCD_RWBIT 1          'LCD read/write bit (Not Used This Time) 
    DEFINE LCD_BITS 4           'LCD bus size 4 or 8 
    DEFINE LCD_LINES 4          'Number lines on LCD 
    DEFINE LCD_COMMANDUS 1500   'Command delay time in us 
    DEFINE LCD_DATAUS 44        'Data delay time in us 
    
    
    ' Main Program                                                 
    '*******************************************************************************
        PAUSE 500      ' Wait .5 second for PIC and LCD to boot
        
        ADCON1 = 7    ' disable A/D converters
        ANSEL = 0     ' disable analog converters
        
        high portc.4   'Turn on LED to show PIC works
        pause 500
        flags = 0      'Put in in case LCD not initialised on power-up
        pause 500
        lcdout $FE,1 ' Clear LCD 
        LCDout "Some words for test" 
        END
    The PIC is working OK (LED lights-up)
    Can you see what I'm doing wrong?
    Attached Images Attached Images  

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. lcd stops after about 5 minutes and gets stuck
    By robertpeach in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th September 2009, 12:03
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43

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