Menu

SSD1331 Problem

John Smith
2025-01-24
2025-02-19
  • John Smith

    John Smith - 2025-01-24

    Hello

    I am trying to use an SSD1331 with a PIC18F47Q43 (also tried a 18F25Q43) and cannot get anything on the display. I have checked the wiring several times, even belled through between the solder connections on the SSD1331 and the legs on the chip to prove no fault with breadboard, ZIF socket, wiring etc.

    Could someone please check the code below to see if I am missing something please?

    The code is from a December 2014 tutorial, I have just taken out bits to simplify it for myself, to add, the LED on portB.5 is flashing so it is going through the code, just the display is dead, I have tested the display with an Arduino and it works OK.

    Regards
    gradall

    /*
        A demonstration program for GCBASIC.
        --------------------------------------------------------------------------------------------------------------------------------
        This program is a simple GLCD demonstration of the SPI capabilities using an GLCD SSD1331.
        It is a nice graphical LCD, suitable for a lot of various projects.
        This program draws lines, boxes, circles and prints strings and numbers.
        The GLCD is connected to the microprocessor as shown in the hardware section of this code.
        :
        This has been tested using the hardware and software SPI option.  If you change from hardware SPI when using PPS, you will need to power cycle the chip.
        :
        :
        @author  EvanV
        @licence GPL
        @version 1.0
        @date    10.12.2024
        ********************************************************************************/
    
    #CHIP 18F47Q43, 64
    #OPTION Explicit
    
        // PIC PPS Tool version: 0.0.6.5
    
        #startup InitPPS, 85
        #define PPSToolPart 18F47Q43
    
        Sub InitPPS
            #IFDEF SSD1331_HardwareSPI
                // Module: SPI1
                RC3PPS = 0x0031    // SCK1 > RC3
                SPI1SCKPPS = 0x0013    // RC3 > SCK1 (bi-directional)
                RC4PPS = 0x0032    // SDO1 > RC4
            #ELSE
                RC4PPS = 0x0000
                RC3PPS = 0x0000
                SPI1SCKPPS = 0x0000
            #ENDIF
    
            End Sub
    
        // ******************* GLCD setup and configuratio ******************
        #INCLUDE <glcd.h>
        #define GLCD_TYPE GLCD_TYPE_SSD1331
    
    
        // This is a PPS chip, so, needs to make the PPS match these assignments
        #DEFINE GLCD_DO     portC.4
        #DEFINE GLCD_SCK    portC.3
    
        // Pin mappings for GLCD
        #DEFINE GLCD_DC     portC.0
        #DEFINE GLCD_CS     portC.1
        #DEFINE GLCD_RESET  portC.2
    
        //! Uncomment out the next line... and, enable or disable the PPS!!!
        //#DEFINE SSD1331_HardwareSPI    ' remove/comment out if you want to use software SPI
    
    
    //  ********************** DEMO REALLY STARTS HERE ************************************************
    
        // GLCD selected OLED font set.
        #define GLCD_OLED_FONT
        #define GLCD_PROTECTOVERRUN
        GLCDfntDefaultsize = 1
    
    
    
        Dim CCOUNT, BYTENUMBER, OLDFONT, OLDFONT as Byte
    
    
        GLCDSetContrast ( 0xFF )
        SetPowerMode_SSD1331(0x1A)                    // Explicit commmands for this device
        SetBrightness_SSD1331( 0xFF )                 // Explicit commmands for this device - full brightness
    
        GLCDCLS
        GLCDPrintStringLN "GCBASIC 2024"
        GLCDPrintStringLN ""
        GLCDPrintStringLN "SSD1331 GLCD"
        GLCDPrintStringLN ""
        GLCDPrintStringLN "by  Anobium"
        wait 5 s
    
    DO forever
    
        'Lighten Arduinos onboard LED for 100 milliseconds
        PulseOut PortB.5, 100 ms
    
        'Then wait 900 milliseconds after LED goes off
        Wait 900 ms
    
    Loop
        End
    
     
  • Anobium

    Anobium - 2025-01-24

    The code looks good.

    I will test on the test rig but it will be Sunday.

    Evan

     
  • John Smith

    John Smith - 2025-01-24

    Many thanks

    Looking forward to your testing, I have been trying for a week now, tried again with a new PIC delivered this morning, still the same.

    To add, when I test the display on Arduino and it works, this is using Arduino IDE (not gcbasic), I am very new to GCbasic so I may be doing something wrong with the GC IDE?

    Regards
    gradall

     
    • Anobium

      Anobium - 2025-01-25

      I got to it today. All good.

      I took your code from the post and tested as-as. Worked.

      I tested as-is using software SPI and then I enabled PPS - that worked.


      Post the top few lines of the ASM file. It will look like this.

      ;Program compiled by GCBASIC (2025.01.21 (Windows 64 bit) : Build 1460) for Microchip MPASM/MPLAB-X Assembler using FreeBASIC 1.07.1/2025-01-22 CRC248
      ;Need help? 
      ;  Please donate to help support the operational costs of the project.  Donate via https://gcbasic.com/donate/
      ;  
      ;  See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
      ;  Check the documentation and Help at http://gcbasic.sourceforge.net/help/,
      ;or, email us:
      ;   evanvennn at users dot sourceforge dot net
      ;********************************************************************************
      ;   Installation Dir : C:\GCstudio\gcbasic
      ;   Source file      : C:\GCstudio\gcbasic\demos\first-start-sample.gcb
      ;   Setting file     : C:\GCstudio\gcbasic\use.ini
      ;   Preserve mode    : 2
      ;   Assembler        : GCASM
      ;   Programmer       : C:\GCstudio\gcbasic\..\PICKitPlus\PICKitCommandline.exe
      ;   Output file      : C:\GCstudio\gcbasic\demos\first-start-sample.asm
      ;   Float Capability : 255
      ;********************************************************************************
      

      Then, try my HEX, and test.

       
      • John Smith

        John Smith - 2025-01-25

        Sorry, as I say, I am very new to GCbasic.

        Are you saying the code I posted works without changing anything?

        Today, I took delivery of a PIC16F17126 (as used in one of your youtube video's) and copied and pasted your code from github as below.

        16F17126_chiprange_demonstrations/260_spi_glcd_using_SSD1331.gcb

        Still the same for me, display is dead?

         
        • Anobium

          Anobium - 2025-01-25

          Did you try the HEX above on the Q43 ? This the latest build with the library fix discussed below.

          And, post the ASM header please. It will tell me your build details.


          I am not saying the display is dead. You have not tried the Hex or the new library.

           
          • John Smith

            John Smith - 2025-01-25

            No, I haven't tried your hex yet, will do tomorrow, reason for tomorrow is, I have another SSD1331 coming from Amazon (should be here this evening) so want to try that also.

            Many thanks.

             
            • John Smith

              John Smith - 2025-01-25

              New SSD1331 has just turned up (via Amazon, a very late delivery).

              This one is actually working, although the display is "strobing", but this is using your code from a few years ago on the PIC16F17126 .

              I am very confused why this one is (semi) working, the old one was dead but worked using an Arduino.

              Will look more into it tomorrow with the other PIC chips and your hex.

              Regards

               
              • John Smith

                John Smith - 2025-01-26

                Just flashed your hex onto my 18F47Q43 and it works fine.

                Thanks for help, so I need to update my glcd_ssd1331.h with a new one from SourceForge?

                Will the other SSD displays also get updated?

                Regards

                 
                • John Smith

                  John Smith - 2025-01-27

                  Just to add as below, small error in help file.

                  https://gcbasic.sourceforge.io/help/_ssd1331_controllers.html

                  Colour "Cyan" isn't valid.

                  Also your post below gives reference to December 2025, a typo I guess?

                  Cracking work you are doing though, many thanks.

                   

                  Last edit: John Smith 2025-01-27
                  • Anobium

                    Anobium - 2025-01-27

                    Thanks!

                    Can you help me with the CYAN error? Not sure I understand what to resolve.
                    Do you mean SSD1331_CYAN is not CYAN colour? Or there is some error.

                    Try using TFT_Cyan.

                    Evan

                     
                    • John Smith

                      John Smith - 2025-01-27

                      Sorry my error, I was supposed to say MAGENTA, it is listed in the SSD1331 help page but it isn't actually declared in the glcd_ssd1331.h file so causing compile error.

                       

                      Last edit: John Smith 2025-01-27
                      • Anobium

                        Anobium - 2025-01-27

                        Here is an improved Help page.

                        It would be best to use TFT colours.

                         
  • Anobium

    Anobium - 2025-01-25

    This is related.... https://ko-fi.com/post/Important-Update-New-Support-for-SPIMode-in-SSD13-E1E819KGZB


    Important Update: New Support for SPIMode in SSD1331 GLCD library

    I have an essential update to share regarding the SSD1331 GLCD library. After years of oversight and valuable feedback from the community, a critical change has been made to enhance its flexibility and usability.

    What's New?

    Previously, the SPI mode was fixed to CPOL = 0 and CPHA = 0. This limitation wasn't ideal for everyone, and I'm now pleased to inform you that I've added support for SPIMode HWSPIClockMode. This means that users can set the SPI mode in their source programs to best suit their needs.

    How to Use It?

    You can set the mode by using #define HWSPIClockMode 0 to 3. This allows you to configure the CPOL (Clock Polarity) and CPHA (Clock Phase) values as follows:

    • 0: CPOL = 0, CPHA = 0

    • 1: CPOL = 0, CPHA = 1

    • 2: CPOL = 1, CPHA = 0

    • 3: CPOL = 1, CPHA = 1

    There is a a library script, that uses the HWSPIClockMode constant in the SSD1331 library to set the operating mode for the GLCD.

    Release Information

    This change was made in December 2024 and is due for release with GCSTUDIO build 1460. The updated library is also downloadable from SourceForge and will be included in the next release of GCSTUDIO.

    Why This Update?

    This update corrects an oversight that persisted for many years. Through my experience with the PIC18F27Q24 tutorials, it was evident that the fixed SPI mode was not suitable for all users. This change provides more control over the SPI communication settings, allowing you to tailor the library to better fit your specific requirements and hardware configurations.

    I hope this update improves your experience with the SSD1331 GLCD library. Thank you for your continued support and feedback. Your contributions are invaluable and help me make these improvements.

    Feel free to reach out if you have any questions, suggestions, or just want to share your experiences!

     

    Last edit: Anobium 2025-01-27
  • Anobium

    Anobium - 2025-02-19

    The latest update, Feb 19th 2025, corrects underlying Hardware SPI issue.

    So, HWSPIClockMode may no longer be required for this library.

     

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.