I am trying to use OLED display in a dspic33f microchip. I've successfully initialized and sent data using I2C to OLED. I managed to display a small font(8pt) on the OLED. However, when I tried a bigger font, part of the font is being obstructed(can't show the whole part of that font).

The code is as the following.

static unsigned char buffer[1024 ] = {      
    // @18 '2' (5 pixels wide)         //generated by using The Dot Factory
    0xC0, 0x80, // ##      #
    0xA0, 0x80, // # #     #
    0x90, 0x80, // #  #    #
    0x8D, 0x80, // #   ## ##
    0x87, 0x00, // #    ###  

    // @9 '2' (4 pixels wide)
    0xC1, // ##     #
    0xA1, // # #    #
    0x91, // #  #   #
    0x8E, // #   ### 

void Oled_init(void){   
    command(0xAE);  //display off
    command(0xD5);  //display clk div
    command(0x80);  //ratio -- continuation of clk_div
    command(0xA8);  //mux ratio
    command(0xD3);  //display offset
    command(0x0);   //no offset- continuation of display_offset
    command(0x40 | 0x00);   //display starting line
    command(0x8D);  //charge pump
    command(0x14);  //internal vcc          
    command(0x20);  //memory mode
    command(0xA1);  //remap columns
    command(0xC8);  //remap rows
    command(0xDA);  //com pins
    command(0x81);  //set contrast
    command(0xDB);  //set Vcomh
    command(0xD9);  //pre charge
    command(0xA4);  //entire display on
    command(0xA6);  //normal display 
    command(0xAF);  //display on    

void display (void){
    command(0x21);  //column start address

    command(0x22);  //set page address
    command(0x00);  //min
    command(0x07);  //max   //128x64resolution

    unsigned int i = 0;
    unsigned char x = 0;

    for(i = 0; i < 1023; i++){
      OpenI2C2(I2CConfig2, I2C2_BRG);
      IdleI2C2 ();
      StartI2C2 ();
      MasterWriteI2C2(0x40);      //Co = 0, D/C = 1, last 6 bit = 0

      for (x = 0; x < 16; x++){   

      StopI2C2 ();

Number "2" with 5 pixels wide

Number "2" with 4 pixels wide

This problem has been troubling me since the last few weeks and I still couldn't find any solution to it. Thanks for any solution in advance.

  • \$\begingroup\$ Is it working with pixel coordinates or character coordinates? Looks like pixel. Just shift them down. \$\endgroup\$ – Eugene Sh. Jul 28 '16 at 14:33
  • \$\begingroup\$ Wait.. I think I've misunderstood how it is supposed to work.. \$\endgroup\$ – Eugene Sh. Jul 28 '16 at 14:43
  • \$\begingroup\$ what does it mean by shift them down? do you mean adding 0x00 in front of the buffer? Eg, static unsigned buffer = { 0x00,0x00,0x00,0x00,...., 0xC0,0x80,0xA0, 0x80,0x90, 0x80, 0x8D, 0x80,0x87, 0x00} \$\endgroup\$ – Allure Jul 28 '16 at 14:44
  • \$\begingroup\$ Can you show the code for the small font? I think the issue is with this 16 in the inner loop. \$\endgroup\$ – Eugene Sh. Jul 28 '16 at 15:02
  • \$\begingroup\$ oh... the code for small font is already in the snippet of code. In the static unsigned buffer, there is a 4 pixels wide data which is {0x00, 0xC1, 0xA1, 0x91,0x8E, 0x00} and how i did was to call the display function right after oled init in the main program. \$\endgroup\$ – Allure Jul 28 '16 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.