• AVR Freaks

Hot!SSD1306 PIC18F Assembly Initialization in SPI

New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2019/09/19 11:53:47
  • Location: 0
  • Status: offline
2019/09/20 09:22:28 (permalink)

SSD1306 PIC18F Assembly Initialization in SPI

    Hello all forum members!
    I am trying to write assembly language code for use in a project that I am working on using the SSD1306 128x32 OLED w/ SPI and PIC Microcontroller. I have searched quite a bit but find almost nothing for this topic using SPI and assembly language. I thought I would give this forum a shot to see I could solve my issues w/ this project as described below.
       Please see attached a copy of my code written for a PIC18LF26K22 in assembly for SPI and OLED SSD1306.
      Now for the issues that I am having. I have read the datasheet and followed the Initialization sequence listed on page 64. I have also written my code to perform the needed reset before initializing the SSD1306. I then, in my code, wrote code to turn on a column of 8 bits on a page to show that my code works. I am using SPI mode 0 but have tried all modes with no difference in the outcome of the OLED not initializing. I have my PIC18LF on a breadboard running from a 3.3v LDO reg that I have used in many projects in the past and that is feeding the OLED which I have mounted to a Crystalfontz board which is for this OLED display. I have checked all connections and have also checked the Crystalfontz board for shorts which turned up none with my multi-meter continuity check. I have used the debugger w/ MPLABX and single stepped through all the code and have placed a blinking LED at the end of my code to signal to me that the code did complete of which it did. All settings for initializing the SSD1306 are taken from the Crystalfontz SPI Code for their 128x32 OLED.
No matter what I have tried I am not able to get this display to power up.

If anyone has any suggestions please post them here.

Thank you all!

1 Reply Related Threads

    Super Member
    • Total Posts : 27057
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: SSD1306 PIC18F Assembly Initialization in SPI 2019/09/21 04:28:56 (permalink)
    It's usual to read the SSPBUF register at the end of the transfer sequence to clear the BF flag.
    I am aware that SOME PICs clear it automatically when the Master writes to SSPBUF, but are you sure your PIC is one of those?
    Adding a dummy read of SSPBUF at the end of the SPI() function might help.
    Also, you are running your SPI at max possible speed (Fosc/4).
    Try running it at a slower speed initially, and only crank the speed up once everything else is working.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    Jump to:
    © 2020 APG vNext Commercial Version 4.5