Hi Richard, & all others in the post.

I've just started out with my OLED display, writing in PIC assembler so I'm presently reading the fine-print on the SSD1306 datasheet to ensure I leave no bits un-turned. I'm cross-referencing my program to others I've found, albeit none in assembler, as such I joined the forum to maybe smooth any glitches I stumble across as this discussion seems rather detailed.

Although the datasheet shows an approximate Initialise flowchart, I've noticed a few differences (in order) between some of the subroutines I've found:

An interesting one within the datasheet informs the Set-Charge-Pump command (8Dh) should be followed by the Display On (AFh) command, has yours been okay as such in your Richard?

Your 'set lower column address' & 'set higher column address', should these variables not be preceded with the actual 'Set Column Address' command, 21h?

Also, the 'Internal IREF Setting' command ($AD) , where in the datasheet is that command listed, I can find ample references to the Iref current & the calcs etc but can'f find the actual command.

If your sequence has proved okay, I'll use its order as a reference to set mine up, although I'll set Segment-0 as column-0 just to get it up & running then make changes as required.

Albeit writes to my CGRAM showed a blank display, as such I've yet to find if it's either my I2C timing (I'm bit banging), (OR) my actual programming sequence, hence firstly confirming the Initialise sequence.

This is my sequence;

0AEh ; Set Display OFF. AE h = display OFF, while AF= display ON.
0D5h ; Set Display Clock Divide Ratio/ Oscillator Frequency.
80h ; (value)
0A8h ; Set Multiplex Ratio.
3Fh ; (value)
40h ; Set Display Start Line (row) 0 - 63 (40h 7Fh). [as I'm using the 64x32 display]
20h ; Set Memory Addressing Mode;
00h ; Three choices, I use the Horizontal mode.
21h ; Set Column Address;
00h ; Column start address (0 for me)
3Fh ; Column end address (63 for me) [as I'm using the 64x32 display]
22h ; Set Page Address;
00h ; PAGE start address (0 for me).
03h ; PAGE end address (3 for me). [as I'm using the 64x32 display]
81h ; Set Contrast Control.
0CFh ; (value)
0D9h ; Set Pre-charge period.
0F1h ; (value)
0DBh ; Set VCOMH Deselect Level.
40h ; (value)
0A4h ; Entire display on. A4h= Display as per RAM content. A5h= Display is ON, **BUT** unafected by changes to RAM content.
0A6h ; Set Normal/Inverse Display. A6h= normal, A7h= inverse.
0x8D ; Set charge pump;
0x14 ; (value) - ON
0AFh ; Turn Display ON.

Mark.
------------

'======= SSD1306 I2C OLED initialization ================================================== =========
COM = $AE : GOSUB SEND_COMMAND ' turn off OLED panel
COM = $D5 : GOSUB SEND_COMMAND ' set display clock divide ratio/oscillator frequency
COM = $F0 : GOSUB SEND_COMMAND ' set divide ratio
COM = $A8 : GOSUB SEND_COMMAND ' set multiplex ratio
COM = $27 : GOSUB SEND_COMMAND ' 1/40 duty
COM = $D3 : GOSUB SEND_COMMAND ' set display offset
COM = $00 : GOSUB SEND_COMMAND
COM = $40 : GOSUB SEND_COMMAND ' set display start line
COM = $8D : GOSUB SEND_COMMAND ' set Charge Pump enable/disable
COM = $14 : GOSUB SEND_COMMAND ' set(0x10) disable
COM = $20 : GOSUB SEND_COMMAND ' Addressing Setting Command Table
COM = $00 : GOSUB SEND_COMMAND ' Page Addressing Mode
COM = $A1 : GOSUB SEND_COMMAND ' set segment re-map: column address 127 is mapped to SEG0
COM = $C8 : GOSUB SEND_COMMAND ' Set COM Output Scan Direction 64 to 0
COM = $DA : GOSUB SEND_COMMAND ' set com pins hardware configuration
COM = $12 : GOSUB SEND_COMMAND ' Sequential COM pin configuration
COM = $AD : GOSUB SEND_COMMAND ' Internal IREF Setting
COM = $30 : GOSUB SEND_COMMAND ' --
COM = $81 : GOSUB SEND_COMMAND ' set contrast control register
COM = $2F : GOSUB SEND_COMMAND ' set contrast value 0..255
COM = $D9 : GOSUB SEND_COMMAND ' set pre-charge period
COM = $22 : GOSUB SEND_COMMAND ' set pre-charge value
COM = $DB : GOSUB SEND_COMMAND ' set vcomh deselect level
COM = $20 : GOSUB SEND_COMMAND ' set vcomh value
COM = $A4 : GOSUB SEND_COMMAND ' Disable Entire Display On
COM = $A6 : GOSUB SEND_COMMAND ' set normal display
COM = $0C : GOSUB SEND_COMMAND ' set lower column address
COM = $11 : GOSUB SEND_COMMAND ' set higher column address
COM = $68 : GOSUB SEND_COMMAND ' set display start line register
COM = $AF : GOSUB SEND_COMMAND ' turn on OLED panel