LPC8xx with OLED Display

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC8xx with OLED Display

1,877件の閲覧回数
ashokfair
Contributor IV

This is simple interface of OLED (128x64) display with LPC804 Micro controller. OLED comes with SSD1306 display controller download the datasheet from here. SSD1306  has SPI and I2C interface but the one which i brought the module has only I2C.

NXP OLED.jpeg

The main reason for this post is, when we search on we about OLED interface lot of  "Arduino" projects works are coming in the results. Only kids will use "Arduino" :smileyhappy:

Here we going to see how we can display text in OLED display.

Step1:  Configure the IO pins for I2C

   

    /* I2C0_SDA connect to P0_7 */
    SWM_SetMovablePinSelect(SWM0, kSWM_I2C0_SDA, kSWM_PortPin_P0_7);

    /* I2C0_SCL connect to P0_14 */
    SWM_SetMovablePinSelect(SWM0, kSWM_I2C0_SCL, kSWM_PortPin_P0_14);

Step2:  Initialize  I2C for default  configuration

    /* Initialize the I2C master peripheral */
    I2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, I2C_MASTER_CLOCK_FREQUENCY);

    /* Create the I2C handle for the non-blocking transfer */
    I2C_MasterTransferCreateHandle(EXAMPLE_I2C_MASTER, &g_m_handle, i2c_master_callback, NULL);

Step3:  Initialize  OLED commands

Sending basic set of commands to SSD1306 via I2C to Init the controller.

OLED_Init(); /*  Cmds details will be provided later */

Step4:  Print Text

The driver logic is same but the way of implementation will be different

void OLED_PrintText(uint8_t line,uint8_t x,uint8_t data[]){

    uint8_t i,j,len,cmax;
    len =strlen(data);
    if( line<8){
        if((x + len*6) > 127){
            cmax=127;
        }
       else
        {
            cmax = x + len*6;
        }
        txBuff[0] = 0x00;
        txBuff[1] = SSD1306_COLUMNADDR;
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,2);
        txBuff[0] = 0x00;
        txBuff[1] = x;
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,2);
        txBuff[0] = 0x00;
        txBuff[1] = cmax;
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,2);
        txBuff[0] = 0x00;
        txBuff[1] = SSD1306_PAGEADDR;
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,2);
        txBuff[0] = 0x00;
        txBuff[1] = line;
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,2);
        txBuff[0] = 0x00;
        txBuff[1] = line;
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,2);
        txBuff[0] = 0x40;
        for(j=0;j<len;j++){
            for(i=0;i<5;i++){
                txBuff[j*6 + i +1] = font[data[j]-32][i];
            }
        }
        I2C_Transfer(SSD1306_I2C_ADDRESS, txBuff,cmax-x +1);
    }
}

To be continue..

ラベル(3)
タグ(4)
1 返信

1,274件の閲覧回数
soledad
NXP Employee
NXP Employee

Thank you for your input!!