This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C drvies 我通过I2C产生了I2c波形时序图是对的,为啥点不亮oled屏呢?以下是部分代码和时序图



//发送数据

void Send_Byte(u8 cmd, u8 dat)
{
    /* Common I2C transaction setup */
       i2cTransaction.writeBuf   = txBuffer;
       i2cTransaction.writeCount = 2;
       i2cTransaction.readBuf    = rxBuffer;
       i2cTransaction.readCount  = 0;

       i2cTransaction.slaveAddress = OLED_SLAVEADDR;
       txBuffer[0] = cmd;
       txBuffer[1] = dat;
       if (!I2C_transfer(I2Chandle, &i2cTransaction)) {
           Log_error0("I2C Transaction fail!");
       }
}

void OLED_WR_Byte(u8 dat,u8 mode)
{

    if(mode != OLED_CMD)
    {
       Send_Byte(0x40, dat);
    }else
    {
        Send_Byte(0x00, dat);
    }


OLED 初始化:
    OLED_WR_Byte(0xAE,OLED_CMD);//--turn off oled panel
    OLED_WR_Byte(0xFD,OLED_CMD);
    OLED_WR_Byte(0x12,OLED_CMD);
    OLED_WR_Byte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
    OLED_WR_Byte(0xA0,OLED_CMD);
    OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
    OLED_WR_Byte(0x3f,OLED_CMD);//--1/64 duty
    OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset   Shift Mapping RAM Counter (0x00~0x3F)
    OLED_WR_Byte(0x00,OLED_CMD);//-not offset
    OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
    OLED_WR_Byte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0×óÓÒ·ŽÖÃ 0xa1Õý³£
    OLED_WR_Byte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0ÉÏÏ·ŽÖà 0xc8Õý³£
    OLED_WR_Byte(0xDA,OLED_CMD);//--set com pins hardware configuration
    OLED_WR_Byte(0x12,OLED_CMD);
    OLED_WR_Byte(0x81,OLED_CMD);//--set contrast control register
    OLED_WR_Byte(0xBF,OLED_CMD);// Set SEG Output Current Brightness
    OLED_WR_Byte(0xD9,OLED_CMD);//--set pre-charge period
    OLED_WR_Byte(0x25,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Cloc
    OLED_WR_Byte(0xDB,OLED_CMD);//--set vcomh
    OLED_WR_Byte(0x34,OLED_CMD);//Set VCOM Deselect Level
    OLED_WR_Byte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
    OLED_WR_Byte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7)
    OLED_Clear();
    OLED_WR_Byte(0xAF,OLED_CMD);

D0:SDA

D2:SCL

D4: RES

  • 你提供的代码没有初始化配置,初始化最好根据我之前提供的两个文档查一下,或者参考下TI I2C例程。硬件方面看一下电源上电是否正确

    时序正确只能表明I2C通路正常
  • 初始化配置:
    I2C_init();//i2c init
    I2C_Params_init(&I2Cparams);
    I2Cparams.bitRate = I2C_100kHz;
    I2Chandle = I2C_open(Board_I2C_TMP, &I2Cparams);
    if(I2Chandle == NULL)
    {
    Log_error0("open i2c init error!");
    return;
    }else{
    Log_info0("open i2c init sucess!");
    }

    OLEDPinHandle = PIN_open(&OLEDPinState, OLEDPinTable);
    if(OLEDPinHandle == NULL)
    {
    Log_error0("open i2c pin error!");
    return;
    }else{
    Log_info0("open i2c pin sucess!");
    }
  • 代码没看出问题,建议你找一下OLED的支持。因为时序图正确,则I2C通路正常,但是发送到外设却没有显示,那最好找一下外设的支持,是不是有什么特殊参数要求,或者电路供电时序