| 我用STM32F10C8T6 连接IIC 接口的OLED。 STM32cubeMX进行初始化设置,以及修改了一下DMA发送函数,发现不能显示
 接口驱动是没问题的,以前用3.5库(没使用DMA)是能正常显示的。
 使用板上的LED灯检查卡在哪,发现卡在第二次发送上。
 下面是精简后的程序,还请大神指导一下。
 
 int main(void)
 {
 HAL_Init();
 SystemClock_Config();
 MX_GPIO_Init();
 MX_DMA_Init();
 MX_I2C1_Init();
 OLED_Init();
 while (1)
 {
 }
 }
 void I2C_Master_Transmit_DMA(uint16_t DevAddress, uint8_t *pData, uint16_t Size)
 {
 while (HAL_I2C_Master_Transmit_DMA(&hi2c1,DevAddress,pData,Size)!= HAL_OK)
 {
 if (HAL_I2C_GetError(&hi2c1)!= HAL_I2C_ERROR_AF)
 {
 Error_Handler();
 }
 }
 }
 void OLED_WR_Byte(uint8_t Byte,uint8_t DC)
 {
 uint8_t SendBuff[2];
 SendBuff[0] = DC;
 SendBuff[1] = Byte;
 I2C_Master_Transmit_DMA(OLED_ADDRESS,SendBuff,2);
 }
 void OLED_Init(void)
 {
 delay_ms(200);              //
 OLED_WR_Byte(0xAE,OLED_CMD);//--display off关闭显示
 OLED_WR_Byte(0x00,OLED_CMD);//---set low column address 设置开始低列地址为SEG0
 /*************目的测试卡在哪*********************/
 HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_SET);
 OLED_WR_Byte(0x10,OLED_CMD);//---set high column address设置高列地址为0000b
 OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  设置开始行地址
 OLED_WR_Byte(0xB0,OLED_CMD);//--set page address        设置开始页地址PAGE0
 OLED_WR_Byte(0x81,OLED_CMD); // contrast control对比度控制,双字节命令
 OLED_WR_Byte(0xFF,OLED_CMD);//--对比度为256
 OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap SEG0列地址为127
 OLED_WR_Byte(0xA6,OLED_CMD);//--设置为正常显示(正常 / 反相显示)
 OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)设置驱动路数
 OLED_WR_Byte(0x3F,OLED_CMD);//--驱动路数为1/32 duty占空比
 OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction: Scan from COM[N-1] to COM0
 OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
 OLED_WR_Byte(0x00,OLED_CMD);//
 OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
 OLED_WR_Byte(0x80,OLED_CMD);//
 OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
 OLED_WR_Byte(0x05,OLED_CMD);//
 OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
 OLED_WR_Byte(0xF1,OLED_CMD);//
 OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
 OLED_WR_Byte(0x12,OLED_CMD);//
 OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh设置电压
 OLED_WR_Byte(0x30,OLED_CMD);//
 OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable设置电荷泵
 OLED_WR_Byte(0x14,OLED_CMD);//开电荷泵
 OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel,开始显示
 }
 |