请教ssd1327刷屏无效

2019-07-20 19:11发布

本帖最后由 yanzhongsan 于 2016-10-19 16:37 编辑

各位好,
在使用stm32f4的SPI端口操作SSD1327时候,初始化应该是成功了,使用命令关闭显示(命令:0xA5)及全屏关闭(命令:0xA6)时正常响应,但是推送数据到显示RAM却没有任何反应,初始化代码如下,显示分辨率为96X96:
函数说明:OLED_SendCMD的原型为:OLED_SendCMD(uint8_t cm0, uint8_t cm1, uint8_t cm2, uint8_t cmd_length); 根据cmd_length来决定是发送多少个命令字节,最多为3个,顺序为cm0cm1cm2;/************************************************************************/
void OLED_SendCMD(uint8_t cmd0, uint8_t cmd1, uint8_t cmd2, uint8_t cmd_length) {
    uint32_t cmd;
    uint8_t *cmdbuf = (uint8_t *) &cmd;

    cmdbuf[0] = cmd0;
    cmdbuf[1] = cmd1;
    cmdbuf[2] = cmd2;

    HAL_SPI_Transmit(&hspi3, cmdbuf, cmd_length, HAL_MAX_DELAY);
}

/************************************************************************/
void OLED_Init(void) {
    OLED_VCC_OFF;
    OLED_RES_HIGH;
    OLED_DC_COMM;


    osDelay(5);
    // Now send the device initialization commands.
    // Unlock the display to accept commands.
    // 0xFD
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_CMD_LOCK, 0x12, 0, 2);


    // Set the display off.
    // 0xAE
    OLED_SendCMD(QG9696TSWHG04_CMD1B_DISPLAY_OFF, 0, 0, 1);
     
    // Set re-map.
    // 0xA0
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_REMAP, 0x53, 0, 2);


    // Set display start line.
    // 0xA1
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_START_LINE, 0x00, 0, 2);


    // Set display offset.
    // 0xA2
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_OFFSET, 0x20, 0, 2);


    // Set Normal display.
    // 0xA4
    OLED_SendCMD(QG9696TSWHG04_CMD1B_SETMODE_NORMAL, 0, 0, 1);


    // Set Multiplex (Mux) ratio.
    // 0xA8
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_MULTIPLEX, 0x60, 0, 2);


    // Function select A.
    // Enable internal VDD regulator.
    // 0xAB
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SELECT_FUNC, 0x01, 0, 2);


    // Set Contrast.
    // 0x81
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_CONTRAST_CURRENT, 0x49, 0, 2);


    // Set Phase Length.
    // 0xB1
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_PHASE_LEN, 0x32, 0, 2);


    // Set front clock divider/oscillator frequency.
    // 0xB3
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_CLK_DIVIDER, 0x51, 0, 2);


    // For Brightness enhancement.
    OLED_SendCMD(0xB4, 0xB5, 0, 2);


    // Set second pre-charge period.
    // 0xB6
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_2ND_PRECHARGE, 0x0D, 0, 2);


    // Set pre-charge voltage.
    // 0xBC
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_PRECHARGE_VOLT, 0x07, 0, 2);


    // Set vcomh.
    // 0xBE
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SET_VCOMH_VOLT, 0x07, 0, 2);


    // Function selection B.
    // 0xD5
    OLED_SendCMD(QG9696TSWHG04_CMD2B_SELECT_FUNC_B, 0x02, 0, 2);


    OLED_VCC_ON;
    osDelay(5);


    // Display ON.
    // 0xAF
    OLED_SendCMD(QG9696TSWHG04_CMD1B_DISPLAY_ON, 0, 0, 1);
}


推送数据的代码如下(实验性质,数据内容仅为测试点亮或熄灭):
typedef union {
    uint32_t u32Buf[1152];
    uint8_t  dispbuf[96][48];
} OLEDBuf_t;
void OLED_Update(uint32_t x, uint32_t y, uint8_t *pdata, uint32_t length) {
    static OLEDBuf_t OLEDBuf;


    for (uint32_t i=0; i<96; i++) {
        for (uint32_t j=0; j<48; j++) {
            OLEDBuf.dispbuf[j] = 0x0f;
        }
    }
    OLED_DC_COMM;
    OLED_SendCMD(QG9696TSWHG04_CMD3B_SET_ROW_ADDR, 0, 0, 2);
    OLED_SendCMD(QG9696TSWHG04_CMD3B_SET_COL_ADDR, 0, 0, 2);


    OLED_DC_DATA;
    HAL_SPI_Transmit_DMA(&hspi3, &OLEDBuf.dispbuf[0][0], sizeof(OLEDBuf_t));
    //HAL_SPI_Transmit(&hspi3, &OLEDBuf.dispbuf[0][0], sizeof(OLEDBuf_t), HAL_MAX_DELAY);
}

在我修改显示内容为0或者0xff屏幕均没有任何反应,请问是哪里有什么问题呢?DMA传输完成中断会发生,意味着是有数据发送出去的。

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。