Menu

SD1306 not displaying correctly

2021-03-25
2021-03-26
  • James Whyte

    James Whyte - 2021-03-25

    I am having trouble with the SD1306 not displaying correctly.
    Initial clear screen seems to give static, and can I get a messy 'hello world'.
    The second clearscreen doesn't seem to do anything, the "hello world" remains
    The second line of text 'Test 2' writes over top of the 'hello world'.
    See attached image.

    I have two of these SD1306 and get the same result, so doesn't appear to be a duff unit, but maybe it is not SD1306 compatable as claimed?

    I have also tried the demo code "GLCD_Simple_Demonstration_Software_SPI_mega328p_for_SSD1306@16.gcb" modified for my pic and hardware etc, but with the same on screen 'static' result

    Is there anything stupid I have missed?

    Great Cow BASIC (0.98.06 2019-06-12 (Windows 32 bit))

      #chip 16F1788, 4.096
      #config OSC = XT, MCLRE_on, PWRT_ON
      #include <glcd.h>
    
    ; ----- Define GLCD Hardware settings
        #define GLCD_TYPE GLCD_TYPE_SSD1306
    
        ; ----- Define Hardware settings
        #define S4Wire_DATA
    
        #define MOSI_SSD1306 PortC.3  ;D1/SCK;SCL pin 14
        #define SCK_SSD1306  PortC.4  ;D0/SDA pin 15
        #define DC_SSD1306   PortA.3  ;pin 5
        #define CS_SSD1306   PortA.4  ;pin 6
        #define RES_SSD1306  PortA.0  ;pin 2
    
        GLCDCLS
        GLCDPrint (30, 0, "Hello????")
        GLCDCLS
        GLCDPrint (30, 50, "Test 3")
    
        end
    
     

    Last edit: James Whyte 2021-03-25
  • Anobium

    Anobium - 2021-03-25

    @kent_twt4

    James - I do not have a 4 wire SDD1306. I only have I2C devices. @kent_twt4 added the 4wire SPI and Kent is good.

    So, let us assume the code is good, but, there could be a timing issue in the SPI. The code below revises to code to redirect the SPI write a subroutine in your program. This will enable you to play with the timing. See myS4Wire_SSD1306 - I have changed the loop method but I have changed the clock signal but rotating the variable SSD1306SendByte to create a timed delay on the clock. This method uses the time (four clock cycles) to rotate the byte to create an improved clock signal.

    Anyway... I cannot test. Also, try NOT using the external OSC.

    Let us know what happens.

    #chip 16F1788, 4.096
      #config OSC = XT, MCLRE_on, PWRT_ON
      #include <glcd.h>
    
    ; ----- Define GLCD Hardware settings
        #define GLCD_TYPE GLCD_TYPE_SSD1306
    
        ; ----- Define Hardware settings
        #define S4Wire_DATA
    
        #define MOSI_SSD1306 PortC.3  ;D1/SCK;SCL pin 14
        #define SCK_SSD1306  PortC.4  ;D0/SDA pin 15
        #define DC_SSD1306   PortA.3  ;pin 5
        #define CS_SSD1306   PortA.4  ;pin 6
        #define RES_SSD1306  PortA.0  ;pin 2
    
        GLCDCLS
        GLCDPrint (30, 0, "Hello????")
        GLCDCLS
        GLCDPrint (30, 50, "Test 3")
    
        end
    
    
        #define S4Wire_SSD1306 myS4Wire_SSD1306
    
    sub myS4Wire_SSD1306(in SSD1306SendByte as byte)
    
      Repeat 8
        if SSD1306SendByte.7 = ON then
          MOSI_SSD1306 = 1
        else
          MOSI_SSD1306 = 0
        end if
        SCK_SSD1306 = 0
        rotate SSD1306SendByte left
        SCK_SSD1306 = 1
      End Repeat
    
    end sub
    
     
  • kent_twt4

    kent_twt4 - 2021-03-25

    So I hooked up the UNO and fired up the demo, and there is something to this. I get lots of random pixels, although the general commands seem to execute OK. Still way back on 98.07_RC19, so something went astray, even before then.

     
    • Anobium

      Anobium - 2021-03-25

      @kent_twt4

      Tried the adaptation to the S4Wire_SSD1306 send routine ?

      If that does not work. Then, I need to look at the Transaction code.

       
  • Anobium

    Anobium - 2021-03-25

    @kent_twt4

    Also, rule out all the Text code. Does a line draw ?

     
  • kent_twt4

    kent_twt4 - 2021-03-25

    Substituted @Anobium code, and no difference. Text commands work, line draws work, along with demo circle, filled circle, box, filled box of demo code.

    This could be a CLS problem? Reduced program to just GLCDCLS and therein full screen of random dots.

     
  • James Whyte

    James Whyte - 2021-03-26

    I have also tried S4Wire_SSD1306 with no improvement. Also tried the internal oscillator.
    At kents suggestion of a problem with GLCDCLS I tried just text only with no GLCDCLS, just text only and still get the same as my photo above. Unless the code does a GLCDCLS unprompted by the user code when initializing?

     
    • Anobium

      Anobium - 2021-03-26

      OK. CLS looks like the issue.
      Drawing lines etc tells us the comms protocol all work.

      CLS is call automatically as part of init.

       
    • Anobium

      Anobium - 2021-03-26

      @kent_twt4

      Are you working this issue?

      The cause based on the facts that lines etc work (meaning the comms are all ok) is the Transaction code.

      I can look at the transaction code but unless low memory mode is defined then the code generated should work... clearly adding transaction code has impact the SPI solution.

      I can look this morning to see if I can see anything obvious. But, I dont want to do the same work as you.

       
  • James Whyte

    James Whyte - 2021-03-26

    I thought I would be cunning and clear the screen with spaces.... no improvement. So does that mean text is a also a problem?
    Even the white spaces to the right of "Test" still give 'static'

        GLCDCLS
        GLCDPrint (0, 0, "          ")
        GLCDPrint (0, 8, "          ")
        GLCDPrint (0, 16, "          ")
        GLCDPrint (0, 0, "Test           ")
    
     
  • Anobium

    Anobium - 2021-03-26

    @James - nice idea. What is your time zone? I have an idea.

     
    • Anobium

      Anobium - 2021-03-26

      Things we know work.

      PSet_SSD1306 and therefore Cursor_Position_SSD1306 - these are all needed for LIne etc.

      But, I have found the error!!!!

      `Write_Transaction_Data_SSD1306 ( in SSD1306SendByte as byte ) sends data to the GCLC as follows.

                CS_SSD1306 = 0
                DC_SSD1306 = 0
                S4Wire_SSD1306 SSD1306SendByte  'were we KNOW this works.
                DC_SSD1306 = 1
                CS_SSD1306 = 1
      

      but, this should be as follows:

        CS_SSD1306 = 0
        DC_SSD1306 = 1
        S4Wire_SSD1306 SSD1306SendByte
        DC_SSD1306 = 0
        CS_SSD1306 = 1
        Exit Sub
      

      Please test the attachment. Rename the existing file in your INCLUDE folder.

       
  • James Whyte

    James Whyte - 2021-03-26

    Bingo.... excellent and well done. Thanks Team :-)
    Now CLCDCLS gives a clean screen and other functions text etc now working as expected.

    PS. I am in New Zealand GMT+13

     
  • Anobium

    Anobium - 2021-03-26

    Excellent news. I did a code review and I thought that transaction code did not look correct!

    GREAT!!

    @kent_twt4 - sorted!!!!

     
  • kent_twt4

    kent_twt4 - 2021-03-26

    Thanks to all. All good with the UNO now too.

    @Anobium could you replace the demo file for the M328 to revised pin placements? This is to reflect the defines to the 4wire SPI module pin order. Also, places the M328 hardware SCK, MOSI, and SS pins to their respective pins too. Tested. Thanks.

     
    • Anobium

      Anobium - 2021-03-26

      I can replace the demo - what was it called?

       
  • kent_twt4

    kent_twt4 - 2021-03-26

    Sorry,

    glcd_simple_demonstration_software_spi_mega328p_for_ssd1306@16.gcb

     

    Last edit: kent_twt4 2021-03-26
    • Anobium

      Anobium - 2021-03-26

      NP. Found it and updated in Github etc.

       

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.