| Author |
Message |
|
|
Posted: Jul 05, 2011 - 05:49 PM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
Hi guys,
after a few days, reading and re-reading the datasheet I could build a library for this OLED display, integrated with a controller SSD1305.
I can write text, draw a pixel etc., but when I try to read I find myself just bad data, someone can help me, thanks.
Put my code and attach a photo.
p.s. Using a Xmega128A1, default set to 2MHz, and AVR Studio 5.0
Code:
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "SSD1305.h"
#define SSD1305_DATA_PORT PORTH_OUT
#define SSD1305_DATA_DIR PORTH_DIR
#define SSD1305_DATA_PIN PORTH_IN
#define SSD1305_CONTROL_PORT PORTJ_OUT
#define SSD1305_CONTROL_DIR PORTJ_DIR
#define SSD1305_RD (1 << PIN0) //Read
#define SSD1305_WR (1 << PIN1) //Write
#define SSD1305_DC (1 << PIN2) //Data Or Command
#define SSD1305_RES (1 << PIN3) //Reset
#define SSD1305_CS (1 << PIN4) //Chip select
void GLCD_WriteData(unsigned char dataToWrite)
{
SSD1305_CONTROL_PORT |= (SSD1305_RD | SSD1305_DC);
SSD1305_CONTROL_PORT &= ~(SSD1305_CS |SSD1305_WR);
SSD1305_DATA_PORT = dataToWrite;
asm("nop");
SSD1305_CONTROL_PORT |= (SSD1305_WR);
}
void GLCD_WriteCommand(unsigned char commandToWrite)
{
SSD1305_CONTROL_PORT |= (SSD1305_RD);
SSD1305_CONTROL_PORT &= ~(SSD1305_CS |SSD1305_WR | SSD1305_DC);
SSD1305_DATA_PORT = commandToWrite;
asm("nop");
SSD1305_CONTROL_PORT |= (SSD1305_WR);
}
void GLCD_InitializePorts(void)
{
SSD1305_CONTROL_DIR |= (SSD1305_DC | SSD1305_WR | SSD1305_RD | SSD1305_CS | SSD1305_RES); //setta direzione 1 output
SSD1305_DATA_DIR = 0xFF; //setta direzione 1 output
SSD1305_CONTROL_PORT &= ~ (SSD1305_DC | SSD1305_WR | SSD1305_RD | SSD1305_CS | SSD1305_RES); //setta i pin a 0
SSD1305_CONTROL_PORT |= (SSD1305_RES); //Reset High
_delay_ms(1);
SSD1305_CONTROL_PORT &= ~ (SSD1305_RES); //Reset Low
_delay_ms(10);
SSD1305_CONTROL_PORT |= (SSD1305_RES); //Reset High runtime mode
_delay_ms(1);
}
unsigned char GLCD_ReadData(void)
{
unsigned char tmp;
SSD1305_CONTROL_PORT |= (SSD1305_DC | SSD1305_WR);
SSD1305_CONTROL_PORT &= ~(SSD1305_CS | SSD1305_RD);
asm("nop");
SSD1305_DATA_DIR = 0x00;
asm("nop");
tmp = SSD1305_DATA_PIN;
SSD1305_CONTROL_PORT |= (SSD1305_RD);
return tmp;
}
unsigned char GLCD_ReadByteFromROMMemory(unsigned char * ptr)
{
return pgm_read_byte(ptr);
}
void GLCD_Initialize(void)
{
GLCD_InitializePorts();
GLCD_WriteCommand(SSD1305_DISPLAYOFF); // 0xAE
GLCD_WriteCommand(SSD1305_SETDISPLAYCLOCKDIV); // 0xD5
GLCD_WriteCommand(0x80); // the suggested ratio 0x80
GLCD_WriteCommand(SSD1305_SETMULTIPLEX); // 0xA8
GLCD_WriteCommand(0x3F); // 0x3F 1/64 duty
GLCD_WriteCommand(SSD1305_SETDISPLAYOFFSET); // 0xD3
GLCD_WriteCommand(0x0); // no offset
GLCD_WriteCommand(SSD1305_SETSTARTLINE); // line #0
//GLCD_WriteCommand(SSD1305_SEGREMAP1); //0xA1
GLCD_WriteCommand(SSD1305_COMSCANDEC); //0xC8
GLCD_WriteCommand(SSD1305_SETCOMPINS); // 0xDA
GLCD_WriteCommand(0x12); // disable COM left/right remap
GLCD_WriteCommand(SSD1305_SETCONTRAST);
GLCD_WriteCommand(0xFF);
GLCD_WriteCommand(SSD1305_SETPRECHARGE); // 0xd9
GLCD_WriteCommand(0xF1);
GLCD_WriteCommand(SSD1305_SETVCOMDETECT); // 0xDB
GLCD_WriteCommand(0x40); // 0x20 is default?
GLCD_WriteCommand(SSD1305_DISPLAYALLON_RESUME); // 0xA4
GLCD_WriteCommand(SSD1305_NORMALDISPLAY); // 0xA6
GLCD_WriteCommand(SSD1305_MEMORYMODE); // 0x20
GLCD_WriteCommand(0x00); // 0x0 act like ks0108
GLCD_WriteCommand(SSD1305_SETLOWCOLUMN | 0x0); // low col = 0
GLCD_WriteCommand(SSD1305_SETHIGHCOLUMN | 0x0); // hi col = 0
//GLCD_WriteCommand(SSD1305_SEGREMAP | 0x1);
GLCD_WriteCommand(SSD1305_DISPLAYON);//--turn on oled panel
}
 |
Last edited by Andrea_IT on Jul 07, 2011 - 09:06 AM; edited 2 times in total
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 08:06 PM |
|


Joined: Oct 30, 2002
Posts: 5721
Location: The Netherlands
|
|
| You don't seem to return the dataport back to outputs after reading the response. |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 08:23 PM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
ops, right. Tomorrow I correct it and try.
Hope... |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 11:35 AM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
I have found a solution, but it's a little mistake:
Code:
unsigned char GLCD_ReadData(void)
{
unsigned char tmp;
SSD1305_DATA_DIR = 0x00;
SSD1305_CONTROL_PORT &= ~(SSD1305_CS);
SSD1305_CONTROL_PORT |= (SSD1305_DC | SSD1305_WR);
SSD1305_CONTROL_PORT &= ~(SSD1305_RD);
SSD1305_CONTROL_PORT |= (SSD1305_RD);
SSD1305_CONTROL_PORT &= ~(SSD1305_RD);
SSD1305_CONTROL_PORT |= (SSD1305_RD);
SSD1305_CONTROL_PORT |= (SSD1305_CS);
tmp = SSD1305_DATA_PIN;
SSD1305_DATA_DIR = 0xFF;
return tmp;
}
If you see the code, i must repeat RD (low, hight) 2 time, because the first time i read bad data?
Why????
Do you have a answer?
Tnku very much.
When I finish the library i post it here.
p.s. excuse me for my bad english, Im Italian |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 06:30 PM |
|


Joined: Oct 30, 2002
Posts: 5721
Location: The Netherlands
|
|
| Read the datasheet more carefully... the first byte returned is a dummy and should be discarded. |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 08:11 PM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
Iam a noob, datasheet is in english, some word escape for me
Tnku jayjay1974 |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 08:58 PM |
|


Joined: Oct 30, 2002
Posts: 5721
Location: The Netherlands
|
|
|
|
|
|
|
Posted: Jul 06, 2011 - 10:31 PM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
Yes perfectly. Very fast write and read. I finish library and then share it.
On the web there isnt ssd1305 library.
I draw pixel, line, rec, circle, text and bitmap, now Im tring to show animation. |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 11:52 PM |
|


Joined: Mar 28, 2001
Posts: 20392
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
|
Quote:
I finish library and then share it.
Per me puoi farlo in Italiano o in Inglese.  |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 01:40 AM |
|

Joined: Jan 09, 2007
Posts: 1884
Location: Arlington, Texas, U.S.A.
|
|
|
|
|
|
|
Posted: Jul 07, 2011 - 08:40 AM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
|
Quote:
http://www.newhavendisplay.com/app_notes/OLED_2_23_12832.txt
This use 6800 Parallel Mode, my 8080, but some function are interesting, tnku |
|
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 09:02 AM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
I attach my first release.
p.s. E' bello trovare altri italiani, ogni volta mi sembra di essere solo. |
|
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 10:37 AM |
|


Joined: Mar 28, 2001
Posts: 20392
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
Thanks for sharing your code Andrea. I'm currently playing with a few GLCD for a couple of clients and I think that driver chip number has come up in one of them.
I have forgotten which one though, I have looked at so many in the past few days that my head is spinning...maybe I'm just possesed...
edit as a matter of interst does anyone know of a cross reference chart for different GLCD controllers? There seem to be some with different numbers that are pin and code compatible with each other. |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 11:25 AM |
|

Joined: Jun 11, 2011
Posts: 12
|
|
Surely there are plenty of GLCD controller compatible with each other. Often, many of them are pre-configured, actually, my GLCD BL12832A1 SSD1305 controller which features a factory was set to only use mode 8080. But this can not find it on the datasheet, (IMPORTANT), I had to check with a tester pins BS1 and BS2, and understand how it operated.
I believe that the SSD,SED models, etc will eventually be compatible with each other, the only thing that changes is the address of the command, just replace them and it should go.
Now I want to try a larger GLCD and color soon.
p.s. JS you should write in Italian) |
|
|
| |
|
|
|
|
|
Posted: Jan 23, 2012 - 06:38 AM |
|

Joined: Jan 16, 2012
Posts: 1
|
|
Hi Andrea, I'm working working on a project with a display using the SSD1305 chip and have found this post very helpful, thank you. One thing, my display isn't turning on and I've rechecked my wiring countless times, so I suspect its code, do you have any tips on debugging the code, given that I can't see the response from the SSD chip? I suspect it might be the frequency but I can't find any definitive notes in the data sheets that indicate the codes for the multipliers and what the base frequency is.
Thanks |
|
|
| |
|
|
|
|
|
Posted: May 02, 2012 - 01:45 PM |
|

Joined: May 02, 2012
Posts: 1
|
|
| Hi Andrea, thanks for the library, I consider it very useful. May I ask you about the text management? Does the library provide support for the fonts? Thanks, Gianluca |
|
|
| |
|
|
|
|
|
Posted: Oct 23, 2012 - 09:02 AM |
|

Joined: Jun 08, 2012
Posts: 2
|
|
Hi Andrea, thank you for your code. It really helped me. But could you possible tell me how did you convert the Bitmap to text to display the Bluetooth logo?
Thanks, Gary |
|
|
| |
|
|
|
|
|
Posted: Apr 05, 2013 - 12:38 PM |
|

Joined: Feb 10, 2006
Posts: 3
|
|
| Hi Andrea, any updates on the library? Planning to use this controller in a project, and looking for different sized fonts, more graphics etc. Are you planning release newer versions of the library? |
|
|
| |
|
|
|
|
|