TMDS64EVM: Oled screen issue

Part Number: TMDS64EVM

Hi TI,

 

Hi have a problem with my TMDS64EVM, I cannot use the Oled screen on the board. I think that I communicate with it. I unblocked the reset pin 16 of the GPIO to see the oled screen on the I2C bus but nothing appears on the screen when I execut emy code. Can you help me?

here is my code

#include <kernel/dpl/DebugP.h>
#include <kernel/dpl/ClockP.h>
#include <kernel/dpl/SystemP.h>

#include <drivers/i2c.h>

#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"

#define OLED_ADDR      (0x3C)
#define IOEXP_ADDR     (0x22)

#define OLED_RST_REG   (0x05)   /* Port1 Output */
#define OLED_CFG_REG   (0x0D)   /* Port1 Config */
#define OLED_RST_BIT   (6)      /* P16 */

/* ========================================================= */

static int32_t TCA_WriteReg(
        I2C_Handle hI2c,
        uint8_t reg,
        uint8_t value)
{
    uint8_t tx[2];
    I2C_Transaction trans;

    tx[0] = reg;
    tx[1] = value;

    I2C_Transaction_init(&trans);

    trans.writeBuf     = tx;
    trans.writeCount   = 2;
    trans.slaveAddress = IOEXP_ADDR;

    return I2C_transfer(hI2c, &trans);
}

static int32_t TCA_ReadReg(
        I2C_Handle hI2c,
        uint8_t reg,
        uint8_t *value)
{
    I2C_Transaction trans;

    I2C_Transaction_init(&trans);

    trans.writeBuf     = &reg;
    trans.writeCount   = 1;

    trans.readBuf      = value;
    trans.readCount    = 1;

    trans.slaveAddress = IOEXP_ADDR;

    return I2C_transfer(hI2c, &trans);
}

/* ========================================================= */

static int32_t OLED_Cmd(
        I2C_Handle hI2c,
        uint8_t cmd)
{
    uint8_t tx[2];
    I2C_Transaction trans;

    tx[0] = 0x00;
    tx[1] = cmd;

    I2C_Transaction_init(&trans);

    trans.writeBuf     = tx;
    trans.writeCount   = 2;
    trans.slaveAddress = OLED_ADDR;

    return I2C_transfer(hI2c, &trans);
}

/* ========================================================= */

static void OLED_Reset(I2C_Handle hI2c)
{
    uint8_t val;

    DebugP_log("OLED RESET START\r\n");

    TCA_ReadReg(hI2c, OLED_CFG_REG, &val);

    val &= ~(1U << OLED_RST_BIT);

    TCA_WriteReg(hI2c,
                 OLED_CFG_REG,
                 val);

    TCA_ReadReg(hI2c, OLED_RST_REG, &val);

    val &= ~(1U << OLED_RST_BIT);

    TCA_WriteReg(hI2c,
                 OLED_RST_REG,
                 val);

    ClockP_usleep(10000);

    val |= (1U << OLED_RST_BIT);

    TCA_WriteReg(hI2c,
                 OLED_RST_REG,
                 val);

    ClockP_usleep(100000);

    DebugP_log("OLED RESET DONE\r\n");
}

/* ========================================================= */

static void OLED_Init(I2C_Handle hI2c)
{
    OLED_Cmd(hI2c, 0xAE);

    OLED_Cmd(hI2c, 0xD5);
    OLED_Cmd(hI2c, 0x80);

    OLED_Cmd(hI2c, 0xA8);
    OLED_Cmd(hI2c, 0x0F);

    OLED_Cmd(hI2c, 0xD3);
    OLED_Cmd(hI2c, 0x00);

    OLED_Cmd(hI2c, 0x40);

    OLED_Cmd(hI2c, 0x8D);
    OLED_Cmd(hI2c, 0x14);

    OLED_Cmd(hI2c, 0x20);
    OLED_Cmd(hI2c, 0x00);

    OLED_Cmd(hI2c, 0xA1);
    OLED_Cmd(hI2c, 0xC8);

    OLED_Cmd(hI2c, 0xDA);
    OLED_Cmd(hI2c, 0x02);

    OLED_Cmd(hI2c, 0x81);
    OLED_Cmd(hI2c, 0x8F);

    OLED_Cmd(hI2c, 0xD9);
    OLED_Cmd(hI2c, 0xF1);

    OLED_Cmd(hI2c, 0xDB);
    OLED_Cmd(hI2c, 0x40);

    OLED_Cmd(hI2c, 0xA4);
    OLED_Cmd(hI2c, 0xA6);

    OLED_Cmd(hI2c, 0xAF);

    DebugP_log("OLED INIT DONE\r\n");
}

/* ========================================================= */

static void OLED_AllPixelsOn(I2C_Handle hI2c)
{
    DebugP_log("FORCE ALL PIXELS ON\r\n");

    OLED_Cmd(hI2c, 0xA5);
}

/* ========================================================= */

void i2c_oled_main(void *args)
{
    I2C_Handle i2cHandle;

    Drivers_open();
    Board_driversOpen();

    i2cHandle = gI2cHandle[CONFIG_I2C0];

    DebugP_log("\r\n");
    DebugP_log("OLED PROBE = %d\r\n",
               I2C_probe(i2cHandle, OLED_ADDR));

    DebugP_log("TCA  PROBE = %d\r\n",
               I2C_probe(i2cHandle, IOEXP_ADDR));

    OLED_Reset(i2cHandle);

    OLED_Init(i2cHandle);

    ClockP_sleep(1);

    OLED_AllPixelsOn(i2cHandle);

    while(1)
    {
        ClockP_sleep(1);
    }
}