Help, OLED Display / 128X64 SSD1306

Başlatan buntger, 25 Mayıs 2013, 00:59:37

buntger

Hello,

Buy this Oled screen of 0.96 ", but so far it works.
I work connecting to the I2C Bus, the Micro is a 18F4550 to 20MHz.

Oled Display Image and Data Sheet: http://www.ebay.co.uk/itm/0-96-128x6...-/130536921656

Pins Board:
-----------------------
3V3 --- D0 (SCLK)
RS --- D1 (SDIN)
CS --- D2
WR --- D3
RD --- D4
RES --- D5
VIN --- D6
GND ---D7

Connection ProtoBoard:
------------------------------------
D1/LCD (SDIN) => PIC/B0 (SDA)
D0/LCD (SCLK) => PIC/B1 (SCL)
3V3 => 3V3 (VCC)
VBAT/LCD => +
BS0/LCD => 0
BS1/LCD => 1
BS2/LCD => 0
VIN/LCD unknow 3V3 (VCC)
GND => GND
*The other pins are not connected (RS,CS,WR,RD,RES, D02 to D7).

I have doubts about the direction of I2C Control Bus.!!

If is = 0111100 = Hex 3C (7 Bits)
or 011110 00 = Hex 78 (8 Bits)

According with Data Sheet, Slave address bit.

'b7 b6 b5 b4 b3 b2 b1 b0
'0 1 1 1 1 0 SA0 R/W# R/W# 1 =Read 0=Write

At the moment the code doesn´t work. HELP!!

THX.

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''
' CODE
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''

Device = 18F4550 'Work PIC
Declare Xtal 20 'Set 20Mhz

All_Digital true 'Set All Digital Port

'Pins, I2C BUS ----------------------------------------------
Declare I2C_Slow_Bus On 'SLow el bus I2C
Declare SDA_Pin PORTB.0 'I2C (SDA)
Declare SCL_Pin PORTB.1 'I2C (SCL)
Declare Hbus_Bitrate 100 'I2C Bitrate 100Hz

'------------------------------------------------------------
' Program
'-------------------------------------------------------------
DelayMS 200 ' Wait for the PIC® micro to stabilise

'Initialitation of display Commands (data Sheet)
HBStart           'Send a Start condition to the I2C bus
HBusOut 0x3C 'Control, (Slave address)
HBusOut 0      'LowByte R/W#=0
HBusOut 0xAE 'Display off
HBusOut 0xD5 'Set Osc Frequency
HBusOut 0x80
HBusOut 0xA8 'Set Mux Ratio
HBusOut 0x3F
HBusOut 0xD3 'Set Display Offset
HBusOut 0x00
HBusOut 0x8D 'Set charge Pump regulator
HBusOut 0x14 'Or 0x10
HBusOut 0xA1 'Set Segment re-map or 0xA0
HBusOut 0xC8 'Set COM Output Scan Direction or 0xC0
HBusOut 0xDA 'Set COM pins Hardware Configuration
HBusOut 0x12 'or 0x02
HBusOut 0x81 'Set Contrast Control
HBusOut 0x81 'or 0x22, 0xCF
HBusOut 0xD9 'Set Pre-Charge Period
HBusOut 0xF1 'or 0xF22
HBusOut 0xDB 'Set VCOMH Deselect Level (Display Start Line)
HBusOut 0x40 'Display Start At 0
HBusOut 0xA5 'Set Disable Entire Display On or 0xA4h
HBusOut 0xA6 'Set Normal/ A7h Inverse Display
HBusOut 0xAF 'Set Display ON
HBStop 'Send a Stop condition to the I2C bus


Ini:
DelayMS 1000
'HBusOut 0x3C 'Control, (Slave address)
'HBusOut 0 'LowByte R/W#=0
HBReStart 'Send a Restart condition
HBusOut $A7 'All Pixels ON
DelayMS 1000
HBusOut $A6 'All Pixels OFF
DelayMS 1000
HBusOut 0xAE 'Display OFF
HBStop
GoTo Ini

End

Burak B

#1
What about CS line ? Are you sure you can control it properly ? If I were you i use this LCD in SPI mode. Just change BS0, BS1, BS2. But if you insist on I2C, i prefer you an I2C scan first.  Scan 0-255 adress range and check if I2C acknowledge will occured. I think your problem is CS(Chip Select) line here. You must lower CS line to control and command to the LCD.

btw. Check controller datasheet on page 19.
It says "Both the data and clock signals must be connected to pull-up resistors." is this OK with you?
"... a healthy dose of paranoia leads to better systems." Jack Ganssle

buntger

Hello,

Searching and searching I found this schematic with multiple connections and others:
http://www.buy-display.com/download/...nterfacing.pdf
http://www.buy-display.com/default/o...ufacturer.html
for now, I'm interested to work with I2C bus.

And with that information reconfigure the wiring, now this:
Connection ProtoBoard:
------------------------------------
D1/LCD (SDIN) => PIC/B0 (SDA)
D0/LCD (SCLK) => PIC/B1 (SCL)
3V3 => 3V3 (VCC)
VBAT/LCD => +
BS0/LCD => 0
BS1/LCD => 1
BS2/LCD => 0
VIN (VCOMH)=> Capacitor 4,7uF Not Pol. to GND
GND => GND
RS(SAO)= GND
CS=> GND
WR=> GND
RD=> GND
RES=> PIC/E0

* View page 16 Data Sheet

'----------------------------------------
'New added below Code:
'----------------------------------------
Symbol ResetInput = PORTE.0 'Res#

Dim LCD_DATA As Byte
Dim X As Byte 'LCD POSITION X(0 TO 127)
Dim Y As Byte 'LCD POSITION X(0 TO 7)
Dim I As Byte

ResetInput=1
DelayMS 100

HBStart 'Send a Start condition to the I2C bus
HBusOut $78 'Slave Adress
HBusOut 0x80 ;
HBusOut 0xae ;//--turn off oled panel
HBusOut 0x80 ;
HBusOut 0xd5 ;//--set display clock divide ratio/oscillator frequency
HBusOut 0x80 ;
HBusOut 0x80 ;//--set divide ratio
HBusOut 0x80 ;
HBusOut 0xa8 ;//--set multiplex ratio 1 to 64
HBusOut 0x80 ;
HBusOut 0x3f ;//--1/64 duty
HBusOut 0x80 ;
HBusOut 0xd3 ;//-set display offset
HBusOut 0x80 ;
HBusOut 0x00 ;//-not offset
HBusOut 0x80 ;
HBusOut 0x8d ;//--set Charge Pump enable/disable
HBusOut 0x80 ;
HBusOut 0x14 ;//--set 0x10 disable
HBusOut 0x80 ;
HBusOut 0x40 ;//--set start line address
HBusOut 0x80 ;
HBusOut 0xa6 ;//--set normal display
HBusOut 0x80 ;
HBusOut 0xa4 ;//Disable Entire Display On
HBusOut 0x80 ;
HBusOut 0xa1 ;//--set segment re-map 128 to 0
HBusOut 0x80 ;
HBusOut 0xC8 ;//--Set COM Output Scan Direction 64 to 0
HBusOut 0x80 ;
HBusOut 0xda ;//--set com pins hardware configuration
HBusOut 0x80 ;
HBusOut 0x12 ;
HBusOut 0x80 ;
HBusOut 0x81 ;//--set contrast control register
HBusOut 0x80 ;
HBusOut 0x8F ;
HBusOut 0x80 ;
HBusOut 0xd9 ;//--set pre-charge period
HBusOut 0x80 ;
HBusOut 0xf1 ;
HBusOut 0x80 ;
HBusOut 0xdb ;//--set vcomh
HBusOut 0x80 ;
HBusOut 0x40 ;
HBusOut 0x80 ;
HBusOut 0xaf ;//--turn on oled panel
HBStop


Oled:
HBStart
HBusOut $78
HBusOut $80
HBusOut $A7
HBusOut $00

X=0
Y=0
GoSub SET_XY
For I=0 To 127
LCD_DATA = LookUp I,[$00,$40,$60,$50,$7E,$50,$60,$40,$02,$06,$0E,$1E,_
$3E,$00,$00,$00,$00,$00,$00,$00,$00,$1F,$3F,$60,_
$60,$60,$60,$60,$60,$3C,$1C,$00,$00,$7F,$7F,$61,_
$61,$61,$61,$61,$61,$3F,$1E,$00,$00,$1E,$3F,$61,_
$61,$61,$61,$61,$61,$38,$18,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$1F,_
$3F,$60,$60,$60,$60,$60,$60,$3C,$1C,$00,$00,$1E,_
$3F,$61,$61,$61,$61,$61,$61,$38,$18,$00,$00,$3F,_
$7F,$60,$18,$06,$06,$18,$60,$7F,$3F,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$1C,$63,$41,$5D,$41,_
$5D,$41,$5D,$41,$5D,$41,$7F,$00]
HBusOut LCD_DATA
Next I

X=0
Y=1
GoSub SET_XY
HBStop
DelayMS 4000
Goto Oled

SET_XY:
HBusOut $21
HBusOut X
HBusOut 127
HBusOut $22
HBusOut Y
HBusOut Y
Return

END

------------------------------------------------------
At the moment I don't see a pixel on the screen (Code doesn't Work) and I'm doing tests ..

THX