vv222 / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

I2C problem with tindie 128x64 OLED #204

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,
I am having a problem with tindie I2C oled (SSD1306) with the libray, I do not 
see any display on it.
https://www.tindie.com/products/miker/096-oled-i2c-display/

I am using a custom Arduino board with just the OLED connected.

So I tried differents things to see where is the problem. All test where done 
on the same custom Arduino board.

1st : Launched Adafruit SSD1306 demo code (after changing I2C address to 3C), 
works fine with tindie OLED

2nd : Launched Tindie sample code demo, works fine with tindie OLED 
(oled_test_code located https://sites.google.com/site/0miker0/oled-displays)

3rd : tried u8g code, does not display anything

4th : tried u8g code with Adafruit I2C oled instead of tindie, works fine

so I suspected a problem in I2C command init code to the OLED (but does not 
really make sense since Adafruit demo code works fine with tindie OLED).

So created I created new init sequence into u8g_dev_ssd1306_128x64.c file like 
this and where init sequence was copied from working tindie demo code

/* init sequence tindie 128x64 OLED */
static const uint8_t u8g_dev_ssd1306_128x64_tindie_init_seq[] PROGMEM = {
  U8G_ESC_CS(0),             /* disable chip */
  U8G_ESC_ADR(0),           /* instruction mode */
  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
  U8G_ESC_CS(1),             /* enable chip */

  0x0ae,                /* display off, sleep mode */
    0x0a6,              /* set normal display */
  0x0ae,                /* display off, sleep mode */
  0x0d5, 0x080,     /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
  0x0a8, 0x03f,     /* */

  0x0d3, 0x000,     /*  */

  0x040,                /* start line */

  0x08d, 0x014,     /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */

  0x020, 0x000,     /* page addressing mode */
  0x0a1,                /* segment remap a0/a1*/
  0x0c8,                /* c0: scan dir normal, c8: reverse */
  0x0da, 0x012,     /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
  0x081, 0x0cf,     /* [2] set contrast control */
  0x0d9, 0x0f1,     /* [2] pre-charge period 0x022/f1*/
  0x0db, 0x040,     /* vcomh deselect level */

  0x0a4,                /* output ram to display */
  0x0a6,                /* none inverted normal display mode */
  0x02e,                /* 2012-05-27: Deactivate scroll */ 
  0x020, 0x000,     /* page addressing mode */
  0x0af,                /* display on */

  U8G_ESC_CS(0),             /* disable chip */
  U8G_ESC_END                /* end of sequence */

};

then of course changed the line in the same file to use the new init sequence
#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_tindie_init_seq

Still does not work and it should, so I suspect the problem could come from I2C 
hardware code (repeated start or not, I2C init speed, or other ...)

Could you please point me on where can I do some change on hardware i2c control 
into the u8glib driver ?

Thank you for your help

Original issue reported on code.google.com by ch.hall...@gmail.com on 27 Sep 2013 at 3:46

GoogleCodeExporter commented 8 years ago
low level procedures are here:
http://code.google.com/p/u8glib/source/browse/csrc/u8g_com_i2c.c

plain atmega and arduino code is here:
http://code.google.com/p/u8glib/source/browse/csrc/u8g_com_arduino_ssd_i2c.c

hope this helps.

Original comment by olikr...@gmail.com on 27 Sep 2013 at 6:35

GoogleCodeExporter commented 8 years ago
Thanks for your Quick reply
One question, does the init code command are sent in one shot ie start then all 
command then stop or is There a start between all command ?
Because on the other code I saw There is start + command + code between each, 
that could be a différence,

Original comment by ch.hall...@gmail.com on 27 Sep 2013 at 6:49

GoogleCodeExporter commented 8 years ago
the code uses a lot of repeated starts.

you might change this by commenting out u8g_i2c_stop() at several places. For 
example here:

    case U8G_COM_MSG_WRITE_BYTE:
      //u8g->pin_list[U8G_PI_SET_A0] = 1;
      if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
        return u8g_i2c_stop(), 0;
      if ( u8g_i2c_send_byte(arg_val) == 0 )
        return u8g_i2c_stop(), 0;
      // u8g_i2c_stop();
      break;

But the code is working for the SSD1306. I had personally verified this with an 
ATMEGA328

Can you measure acitivity on the pins? Did you select the correct slave adr?

Original comment by olikr...@gmail.com on 27 Sep 2013 at 7:02

GoogleCodeExporter commented 8 years ago
Yeah, I will try this, I agree, Adafruit works fine that is why I do not 
understand because it is the same controller, and if I test tindie OLED with 
adafruit demo code it works, this drive me nut.

If I can't resolve it I will need to investigate with logic analyser the code 
send

Original comment by ch.hall...@gmail.com on 27 Sep 2013 at 7:18

GoogleCodeExporter commented 8 years ago
Hi,

Ok this is what I thought, took 3 screenshot with 3 different driver, u8g 
driver send all commands in one shot and the other restart a i2c com after each 
command. this is the difference and i think ssd1306 driver is very sensible to 
this. I noticed sometimes that even with u8g and adafruit oled, I needed to 
plug/unplug power several times before oled really start, may be this is due to 
the same thing.

May be we could add a new escape sequence that after each command do a stop, 
then restart a start with address with ometing like that

static const uint8_t u8g_dev_ssd1306_128x64_tindie_init_seq[] PROGMEM = {
  U8G_ESC_CS(0),             /* disable chip */
  U8G_ESC_ADR(0),           /* instruction mode */
  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
  U8G_ESC_CS(1),             /* enable chip */
  U8G_ESC_START(1),       /* start new command */
  0x0ae,                /* display off, sleep mode */
  U8G_ESC_START(1),       /* start new command */
  0x0a6,                /* set normal display */
  U8G_ESC_START(1),       /* start new command */
  0x0d5, 0x080,     /* clock divide ratio (0x00=1) and oscillator frequency (0x8)      ....

What do you think ?

Original comment by ch.hall...@gmail.com on 27 Sep 2013 at 11:25

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry here the correct u8g graph

Original comment by ch.hall...@gmail.com on 27 Sep 2013 at 11:33

Attachments:

GoogleCodeExporter commented 8 years ago
Ok, problem solved, got lucky because tested on another board to do capture and 
it worked 1st time. Only difference was the pull up, so I put pull up (Arduino 
pullup does not seems to be enough). Tha Adafruit Oled has level shifter on 
board with pull up, this is why it was working. All make sense now
You can close the case, sorry it was my mistake.

Once again, thank you for your nice job.

Original comment by ch.hall...@gmail.com on 28 Sep 2013 at 12:26

GoogleCodeExporter commented 8 years ago
Nice screenshots. I wished i had that kind of equpment. Thanks for the 
information. I will close this issue.

Original comment by olikr...@gmail.com on 28 Sep 2013 at 6:03

GoogleCodeExporter commented 8 years ago

Original comment by olikr...@gmail.com on 28 Sep 2013 at 6:04