| View previous topic :: View next topic |
| Author |
Message |
starfire151
Joined: 01 Apr 2007 Posts: 209
|
| SSD1306 with PIC16LF1825 |
Posted: Fri Jun 05, 2026 11:14 am |
|
|
I've looked through the copious amounts of data on the forum related to the SSD1306 OLED. My eyes are numb!
I have an SSD1306 module with the 4-pin I2C interface. I'm trying to run it with a PIC16LF1825. I'm using the ssd1306.h driver from Ttelmah. I'm setting the display up for text only. I have made the following definitions in my header file:
#define TEXT_ONLY
#define WINDOW_WIDTH 128
#define WINDOW_HEIGHT 64
#define S_LCDWIDTH 128
#define S_LCDHEIGHT 64
#define SSDADDR 0x78
In my main program, I #include <ssd1306.h> and during the intitialization, I include the line
OLED_commands(init_sequence, sizeof(init_sequence)); //initialise the OLED
It compiles with no errors. Unfortunately, though, when I download the program and try to start it, it hangs up.
Commenting out the OLED_commands(...) line allows the rest of the program to run correctly. It appears it is getting hung up in the OLED init sequence.
Am I missing something in the initialization?
On a related subject, I am looking into the use of the newer PIC16LF18326 chip as a replacement for the PIC16LF1825 as it has 2K of RAM. Assuming I can get this initialization problem worked out, would this new processor allow the use of graphics on this display, also?
Thanks for any help. |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 564 Location: Montenegro
|
|
Posted: Fri Jun 05, 2026 11:28 am |
|
|
| Try I2C scanner, if your display even is on that address. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20084
|
|
Posted: Fri Jun 05, 2026 12:38 pm |
|
|
Have you got the 250mSec delay before the initialisation?. It is needed.
How is the I2C setup????.
As PrinceNai says, check the I2C address.
What pullups are you using on the I2C bus?.
Describe your connections, and show the I2C setup.
How much RAM you need for graphics depends on how gig you make the
window. You can do small graphics with a small amount of RAM. |
|
 |
starfire151
Joined: 01 Apr 2007 Posts: 209
|
|
Posted: Fri Jun 05, 2026 2:06 pm |
|
|
Thanks for responding.
Yes. I do have the 250ms delay before the call to the init routine.
Is there a snippet of the I2C Scanner I could embed?
I'm using 4.7K pullups on the SDA and SCL lines.
My connections to the OLED are as follows:
OLED pin 1 (Gnd) to circuit ground
OLED pin 2 (Vcc) to circuit power (+3.3VDC)
OLED pin 3 to PIC16LF1825 pin 10 (SCL) and to 4.7K pullup to Vcc
OLED pin 4 to PIC16LF1825 pin 9 (SDA) and to 4.7K pullup to Vcc
My I2C setup is as follows:
#define EEPROM_SDA PIN_C1 // I2C data
#define EEPROM_SCL PIN_C0 // I2C clock
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL, fast, force_hw) |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 564 Location: Montenegro
|
|
Posted: Fri Jun 05, 2026 2:32 pm |
|
|
I2C scanner is in the code library, here
https://www.ccsinfo.com/forum/viewtopic.php?t=49713
At least from my experience I2C does tend to hang the code execution if nothing is there. One thing with cheap displays. Not all of them have the same pin-out. Try swapping SCL and SDA. Also + and - are not always correct. Unlike others, I do use Pickit3 as a debugger, so it is easy to see. Pause the execution and if the arrow is on #use i2c, you have a problem there. I also always use a Heartbeat diode. Blinking, something is happening, my code is garbled but at least executing. Not blinking and using I2C? 99% of the time I2C problem. Waiting for an ACK or something. |
|
 |
starfire151
Joined: 01 Apr 2007 Posts: 209
|
|
Posted: Fri Jun 05, 2026 2:41 pm |
|
|
I got it to work!
I have a LogicPort device and set it up to analyze the I2C port. It was showing some very weirdness. It looks like the I2C peripheral in the PIC has somehow gotten damaged. I put a different PIC16LF1825 in the circuit and the LogicPort showed the correct initialization on address 0x78.
The code is working now.
Thanks ---VERY MUCH--- for your help.
I will also take a look at the I2C scanner code and keep it handy. That sounds like a good way to analyze the bus. |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 564 Location: Montenegro
|
|
Posted: Fri Jun 05, 2026 2:42 pm |
|
|
| Nice :-) |
|
 |
|