[SOLVED !] OLED Display 128x64 0.96 I2C version


Closed Thread
Results 1 to 7 of 7

Thread: OLED Display 128x64 0.96 I2C version1238 days old

  1. #1
    starwars
    Guest starwars's Avatar

    0 Not allowed!

    Default OLED Display 128x64 0.96 I2C version

    Hi
    I had purchased several types of displays to experiment with. However, due to a lack of time (work taking priority) I had kept these aside. I have the SSD1306 I2C type of display shown here: http://artofcircuits.com/product/ssd1306-white-0-96-128x64-oled-display-i2c-interface.

    I bought mine off ebay.

    I have wired the pins as follow SDA --> PortB.2, SCL --> PortB.1

    The relevant portion of the code is here:
    Code:
    Declare Reminders = Off
    Device = 18F26K22                              'Set device
    
    Declare Stack_Size = 10                        'Stack size needed for SSD1306.inc???????????
    Declare Reminders = On
    
    
        ;Internal Oscillator 16Mhz and enable PLL (= 4 * 16 = 64Mhz)
    OSCCONbits_IRCF2 = 1 : OSCCONbits_IRCF1 = 1 : OSCCONbits_IRCF0 = 1  ;16Mhz internal clock
    OSCTUNEbits_PLLEN = 1                       ;Enable PLL 
    DelayMS 50                                  ;After writing these registers the oscillator becomes unstable for a while
    Declare Xtal = 64                           ;16 x 4 = 64Mhz
    
    
    Declare All_Digital = True                      'Set all A\I to be D\I
    Declare SDA_Pin PORTB.2
    Declare SCL_Pin PORTB.1
    
    
    GoTo here
    ;    Include "ssd1306_15.09.2015.inc"            'Include the SSD1306 driver file
        Include "ssd1306_24.11.2016.inc"            'Include the SSD1306 driver file v0.3
    here:
    
    'The display_INIT MUST be used before
    'any variables are initialized. For
    'some reason it clears all RAM when used.
    Display_INIT                                    'Initialize the display
    
    
    Dim var1                    As Word             'Dim var
    Dim loopCount               As Byte             'Dim var, general counter
    Dim offset                  As Word             'Dim var, used in rectanles
    var1        = 0                                 'iniz var
    loopCount   = 0                                 'iniz var
    offset      = 0                                 'iniz var
    
    'SPI bus speed = 1mhz data sheet says 400khz
    'but i have seen no problems at this speed.
    'Declare Hbus_Bitrate  1000
    Declare Slow_Bus On                       
     High PORTA.6
    The include file is borrowed from elsewhere in this forum, I can locate the exact link if someone would like to see it.

    However, the code above doesn't seem to work with the RB Ports.

    What exactly would need to be modified so that I can understand how this code works?

    Thank you for your time

    Harry

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Member Dompie's Avatar
    Join Date
    Apr 2012
    Posts
    155
    Thumbs Up
    Received: 17
    Given: 14
    Total Downloaded
    5.19 GB

    0 Not allowed!

    Default Re: OLED Display 128x64 0.96 I2C version

    The .inc file uses hardware I2C and the hardware pins are defined in the datasheet. If you want to use other pins, you have to change all the hardware related I2C calls too software related calls. Then you can define your own SCL and SDA pins. An Example: the calls to HBUSOUT must be changed to BUSOUT.
    You can look in the manual for all the changes you need to make and the extra Declares you will need. All the HBxxxxx routines have Bxxxxx counterparts (I believe)

    Johan

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,599
    Thumbs Up
    Received: 341
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: OLED Display 128x64 0.96 I2C version

    As Johan has stated. The Hbus commands use the microcontroller's peripheral, and this uses dedicated pins for SCL and SDA.

    To use any pin on a device, or a device that does not have an I2C peripheral on board, use the Bus commands. i.e. Busin, Busout, BStop, BStart, BAck etc...

    The declares required to choose the pins to use are:

    Declare SDA_Pin = Port.Pin
    Declare SCL_Pin = Port.Pin


    The syntax for the HBus and Bus commands are identical.

    If the compiler's I2C routines are running too fast for the chip, use Declare Slow_Bus = 1. This will slow down the I2C coms.

    See pages 127 to 135 of the compiler's PDF manual.

    If several I2C chips require communicating with on different pins, use the I2Cin and I2Cout commands. See pages 258 to 262 of the manual.
    Last edited by top204; 16th January 2017 at 15:57.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    starwars
    Guest starwars's Avatar

    0 Not allowed!

    Default Re: OLED Display 128x64 0.96 I2C version

    Hi Les and Johan
    Many thanks for your replies. I'm using the PIC18F26K22

    As I understand, if I use 'other' pins for the display, I would need to change the Bus commands, but I was planning to use the RB1 (SCL2) and RB2 (SDA2). Hence, I was wondering if there was an alternative in the code to using SDA1 and SCL1.

    Regards

    Harry
    Last edited by starwars; 16th January 2017 at 19:28.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Member Dompie's Avatar
    Join Date
    Apr 2012
    Posts
    155
    Thumbs Up
    Received: 17
    Given: 14
    Total Downloaded
    5.19 GB

    0 Not allowed!

    Default Re: OLED Display 128x64 0.96 I2C version

    Ehhhhhhhh I don't know how to switch from MSSP1 to MSSP2 in I2C. I hadn't notice thatr the 18F26K22 has a second MSSP.
    A quick search gives no answer. I hope Les will answer this question, can we both learn how .

    Johan

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    starwars
    Guest starwars's Avatar

    0 Not allowed!

    Default Re: OLED Display 128x64 0.96 I2C version

    Hi Johan
    Working on the DOGM Module with Barak, I've learned that the SPI mode from MSSp1 to MSSP2 can be changed using this.
    Code:
    ''---[SPI Function]-----------------------------------
    'SPI_GLOBAL:                                         ' generic SPI sub             
    '    Pop SSPBUF                                     ' trasmit a byte from stack
    '    While SSP2IF = 0 : Wend                         ' wait for end of transaction
    '    SSP2IF = 0                                      ' clear the SSP flag
    '    SPI_BYTE_IN = SSP2BUF                           ' nothing to do with the LCD use to read from other slaves
    '    Return  
    
     SPI_GLOBAL:                                         ' generic SPI sub                 
        Pop SSP2BUF                                     ' trasmit a byte from stack
        While SSP2IF = 0 : Wend                         ' wait for end of transaction
        SSP2IF = 0                                      ' clear the SSP flag
        SPI_BYTE_IN = SSP2BUF                           ' nothing to do with the LCD use to read from other slaves
        Return
    I guess some register values also need to be set as
    Code:
        SPI_Con:      
        SSP2CON1 = %00000001               ' configure SPI Master, FOSC/16 so SCL is 1MHz 
        Symbol SSP2EN  = SSP2CON1.5     ' SSP Enable bit
        Symbol CKP2    = SSP2CON1.4     ' Clock Polarity Select
        Symbol SMP2    = SSP2STAT.7     ' Data input sample bit
        Symbol CKE2    = SSP2STAT.6     ' Clock Edge Select bit
        Symbol BF2     = SSP2STAT.0     ' buffer full status bit 1 = buffer full
        Symbol SSP2IF  = PIR3.7         ' interrupt flag - last bit set
    I'm not sure if this also works for I2C or if this is correct way to go about for the I2C, but as you say, let's see what Les says and take it from there.

    Thank you!

    Harry

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Member Dompie's Avatar
    Join Date
    Apr 2012
    Posts
    155
    Thumbs Up
    Received: 17
    Given: 14
    Total Downloaded
    5.19 GB

    0 Not allowed!

    Default Re: OLED Display 128x64 0.96 I2C version

    Hi Harry
    For SPI there are no Proton commands so you have to code it yourself and you can switch from MSSP1 to MSSP2 registers and flags. For I2C we have the Proton commands HBSTART, HBUSOUT, HBUSIN etc. So the coding you did for SPI have to be done inside the Proton commands (by Les I believe).
    I'm wonder if there is a solution at the moment. Perhaps we need the HBSTART2, HBUSOUT2. HBUSIN2 etc. in a future version of the compiler.

    Johan

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Help With OLED Display / 128X64 SSD1306
    By basparky in forum Proton 24
    Replies: 27
    Last Post: 16th March 2019, 17:36
  2. Vishay's OLED Display Modules Now Shipping from Mouser
    By normnet in forum New devices and techniques
    Replies: 0
    Last Post: 13th February 2017, 09:01
  3. Help With OLED Display / 128X64 SSD1306
    By Denner in forum LCD module
    Replies: 69
    Last Post: 8th January 2017, 00:00
  4. [SOLVED !] Arduino Mega 2560 R3 together with I2C Display (Display 20x4 HD44780)
    By Monie in forum Labcenter Proteus VSM
    Replies: 2
    Last Post: 26th June 2016, 07:49
  5. Help Display GLD JHD529M1 128x64
    By kontermas in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 9th February 2010, 16:08

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts