I2C help Please


Results 1 to 7 of 7

Thread: I2C help Please

Threaded View

  1. #2
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: I2C help Please

    I can't see why you don't get at least something out of the data and clock pins, these normally idle High anyways. Watch it with a scope if available.
    Does your program go to NOACK every time? The "END" after it will cause it to stop right there. Put a GOTO Main instead.

    I would also structure your program something like this:
    Code:
    Configs
    pause 2000 ' lcd start up
    i2cwritE DPIN, CPIN, $4C,[$FE, $04, 99],NOACK  'Sets contrast (0-100)
    i2cwritE DPIN, CPIN, $4C,[$FE, $03, 200], NOACK 'Sets the brightness (0-250)
    
    Main:
    I2CWRITE DPIN, CPIN, $4C, [$FE,$14], NOACK   ' Clears screen
    i2cwritE DPIN, CPIN, $4C,["Hello World!"], NOACK    'text sent to the LCD, defaults to row 0, col 0 
    PAUSE 1500 'Next is to make sure all of above worked   
    HIGH PORTD.2   PAUSE 250   
    LOW PORTD.2   PAUSE 250   
    HIGH PORTD.2   PAUSE 250   
    LOW PORTD.2   PAUSE 250   
    HIGH PORTD.2   PAUSE 250   
    LOW PORTD.2   PAUSE 250   
    HIGH PORTD.2   PAUSE 250   
    LOW PORTD.2 goto main   
    
    NOACK:     
    HIGH PORTD.2     
    PAUSE 5000     
    LOW PORTD.2    
    PAUSE 1000 
    GOTO Main       ' Start over
    

    The LCD contrast and brightness only needs to be set up once before the Main loop unless you want to get fancy but save that till later.
    Verify the Address $4C is correct otherwise all your attempts to write to the LCD will be ignored.
    Last edited by LinkMTech; - 27th December 2011 at 15:10. Reason: fixed some confusing typos
    Louie

Members who have read this thread : 0

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