I2C LCD


Closed Thread
Results 1 to 40 of 47

Thread: I2C LCD

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Try this, initalization based on an arduino sketch
    Code:
    'PIC 16F1824
    
    #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011
    
    PORTA = 0  
    PORTC = 0
      
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RS    var PORTC.2 
    symbol mode = $7C
    
    pause 100
    RS = 0
    'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)
    
    '=============Initializing by Instruction==========pag 39 datasheet
    
     
    I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display
     
    'FUNCTION SET 0 and 1 ------------pag 30 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
    pause 10
    
    
    
    'INTERNAL OSC------------pag 35 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v
    
    
    'CONTRAST SET------------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$73]
    
    
    'POWER/ICON/CONTRAST------pag 36 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03
    
    
    'FOLLOWER CONTROL-------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
    pause 10
    
    'DISPLAY ON------------- pag 29 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF
    
    
    
    'CLEAR LCD --------------pag 28 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$01]
    
    
    'ENTRY MODE SET----------
     I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.
    
    
    RS = 1
    pause 500
    
    I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]
    Can you include a high res picture of your display?

  2. #2
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    try this
    Code:
    'PIC 16F1824
    
    #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011
    
    PORTA = 0  
    PORTC = 0
      
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RS    var PORTC.2 
    symbol mode = $7C
    
    pause 100
    RS = 0
    'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)
    
    '=============Initializing by Instruction==========pag 39 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave
     
    I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display
     
    'FUNCTION SET 0 and 1 ------------pag 30 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
    pause 10
    
    
    
    'INTERNAL OSC------------pag 35 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v
    
    
    'CONTRAST SET------------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$73]
    
    
    'POWER/ICON/CONTRAST------pag 36 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03
    
    
    'FOLLOWER CONTROL-------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
    pause 10
    
    'DISPLAY ON------------- pag 29 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF
    
    
    
    'CLEAR LCD --------------pag 28 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$01]
    
    
    'ENTRY MODE SET----------
     I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.
    
    
    RS = 1
    pause 500
    I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave
     
    I2CWRITE PORTC.1, PORTC.0,$7C,[$40] 'Write to display RAM
    I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]
    end

  3. #3
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    or try this,
    Code:
     #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    Reset    var PORTC.2     'could tie reset pin to   vdd through 10K resistor
    
    
    pause 100
    HIGH Reset
    'OPF1 = 0 
    goto StartProgram
    '********************************************************************************
    '=============Initializing LCD==========
    ST7036Init:
    
    
     
    'FUNCTION SET 0 and 1 ------------pag 30 datasheet
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$14,$73,$5E,$6D,$0C,$01,$06] ' 
    
    
    
    Return
    '********************************************************************************
    
    
    
    startProgram:
    gosub  ST7036Init
    I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello
    
    IdleLoop:
          ' could blink an led here
    goto Idleloop

Similar Threads

  1. I2C lcd ( arduino ) with PICBASIC, help
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 92
    Last Post: - 10th September 2014, 19:00
  2. I2C variable to LCD
    By pointjohn in forum Serial
    Replies: 7
    Last Post: - 19th October 2011, 09:53
  3. I2C to LCD display
    By Ron Marcus in forum Serial
    Replies: 3
    Last Post: - 29th December 2007, 15:53
  4. Need cheap i2c LCD for 16F877a
    By CodeShredder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th December 2006, 02:25

Members who have read this thread : 4

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