Help with I2C, SSD1306, and a OLED

SgtB

Member
Hello everyone,

I'm having problems getting a OLED to work. It's an adafruit OLD that uses I2C for comms, and is controlled by a SSD1306 driver.(http://www.adafruit.com/products/931) All of my pins are correct, but I'm having problems deciphering all of the H2icsetup parameters, including the address. I2cout is also confusing me. I can't wrap my head around what my binary strings should look like to get it to listen.

Here is the datasheet:http://www.adafruit.com/datasheets/SSD1306.pdf

On page 20 the i2c protocol is described. I'm trying to use the "Entire display on", and "Set display on " commands, from pg.28, to get the display to just do something but have gotten zero out of it. I'm also curious if the "ACK" signals need to be handled as well.

My code follows. It's trashed due to me trying everything imaginable.
Code:
'*********************************************
'OLED Example test.

Symbol Rst = B.3
Symbol DisplayAddress = %011110010

Init:
Low Rst
pause 1000
high Rst

hi2csetup i2cmaster, DisplayAddress,i2cfast,i2cbyte

do
hi2cout $0,($af,%1)
'hi2cout $0,(%1010111110101111)

loop
Thanks for anyone who looks into this. I already know that I'm getting myself into a mess with the huge amount of addresses the screen has, but I think getting the fundamental comms down will clear %90 of my problems.:D
 
Last edited:

nick12ab

Senior Member
Code:
Symbol DisplayAddress = %011110010
Should be:
Code:
Symbol DisplayAddress = %01111000
or:
Code:
Symbol DisplayAddress = %01111010
Try both.
 

Goeytex

Senior Member
Per Adafruit:

"You'll need a microcontroller with more than 512 bytes of RAM since the display must be buffered."​

I have no experience at all with this controller but that kinda jumped out at me as possibly being relevant.

Please tell us what Picaxe you are using.
 

SgtB

Member
I figured the address was to long the way it stands now. It was %01111010 for many of my tests, I was just playing around with where it was. I keep ending up with more than 16 bits in some of my commands and was trying to see if it could be shifted around.

I'm using an 18m2 right now. I'm waiting on a stronger Uc in the mail right now and was just trying to get some life out of the screen. I figured the "entire screen on" command was a work around for now as it ignores the screens buffer. I'm doing what I can to decipher the i2c commands mostly as a challenge to myself. If I could at least figure out what size chunks I should be sending and what order they should be in, I'd be happy.
 

hippy

Ex-Staff (retired)
HI2cOut <address>, ( <data> )

Is primarily used for memory devices or those with registers. The datasheet shows this device expects just data ( commands or raw display data ) so drop the address and try with ...

HI2cOut ( <data> )

Also, always start with I2CSLOW rather than I2CFAST.
 

SgtB

Member
Thanks hippy. I'll give that a try. I also just realized that the table showed the hex and binary values for the same command right next to each other. I've been doubling everything! :eek:
 

Goeytex

Senior Member
In looking at the Arduino code provided by adafruit the address is

%0111100 or $3C if SAO is grounded or
%0111101 or $3D default

Possibly try:

HI2cSetup i2cmaster, $3C,i2cslow,i2cbyte
pause 10
HI2cOut ( $AF) 'Display on
Pause 10
HI2cOut ($A5) ' Display All on
stop
 
Top