0
\$\begingroup\$

I've been trying to interface SSD1306 I2C oled monochrome display module with PIC18F2550 micro-controller without any success. the datasheet of ssd1306 controller shows the following data formatenter image description here

so can anyone explain the format on how can we implement this in I2C code.I'm using MikroC pro for PIC.

\$\endgroup\$
2
\$\begingroup\$

Definitely have the datasheets for both your MCU and LED Display open as you do this. I'm answering this question based on the datasheets for the MCU and LED here.

  1. Make sure both the MCU and LED Display are properly configured in hardware / software. Look at section 8.1 in the LED datasheet, specific pins must be driven appropriately to configure the chip for I2C. See the MCU datasheet on how to configure the the I2C registers. You should set the clock frequency lower than 400 kHz as this is the maximum the LED supports (Table 13-6 in LED datasheet). Configure your MCU as the I2C Master.

  2. Actual protocol. If you have the I2C library, this should be fairly straight forward. Otherwise, dig through the MCU datasheet / examples on how to do I2C communication. That's too expansive to cover in this post. If you are using the library, the commands are found here http://www.mikroe.com/mikroc/pic/libraries/

*I2C1_Init

*I2C1_Start

*I2C1_Wr

*I2C1_Rd

*I2C1_Stop

Looking at the diagram this is how we would procede

  1. Issue a start command (This is the S at the beginning).

  2. Write the slave address of the LED. The slave address is the "name" of the device on the I2C network. Note that there can potentially be many devices on a I2C line, which is why we need this "name". The name is formed of the upper 7 bits of the first byte. The slave address of the LED is “0111100” or 0x78 in hex. The lowest bit is a R/W or read/write bit. This tells the LED if we want to read or write to the device. In this case, we want to send a command so we want to write. Write is indicated by a 1. Thus the first byte that you should send is a 0x79.

All I2C transfers have a acknowledge bit, this will be returned by the I2C1_Wr function. It should be 0 to represent no errors.

  1. Next we have a command byte. Send a repeated start over I2C using the library function to do so. The OLED has a set of commands that it exposes to the MCU. You can see these in section 9 of the LED datasheet. Pay close attention to section 8.9 of the datasheet, which describes how to turn on the LED. Notably you should send the command 0xAF to turn on the LED.

  2. To write data to the device, look at the diagram labeled Control Byte in your figure. The top bit is labeled D/C indicating data or control byte. By setting this bit appropriate, the byte is processed as a data byte for display or a command byte.

\$\endgroup\$
0
\$\begingroup\$

Use the drivers from the following page. Written for pic18f2550 with mikroc compiler.

http://embeddedlaboratory.blogspot.com/2018/02/oled-i2c-display-using-microchip-pic.html?

\$\endgroup\$
  • \$\begingroup\$ Welcome to EE.SE! Answers that are primarily links are discouraged, as they are short and do not add additional explanation. In the future (when you have more reputation), this may be better served as a comment. \$\endgroup\$ – Daniel Feb 25 '18 at 19:08
  • 1
    \$\begingroup\$ @Daniel Yes you are right. And you also pointed out the reason why i am not able to comment. Will take care of this in future. \$\endgroup\$ – xpress_embedo Feb 26 '18 at 20:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.