0

I have use STM32F0 microcontroller.

I try to integrate the stm32 with OLED(SSD1306:128*64).

It's an I2C communication. The issue is while clearing the display takes some seconds(like 2sec.).

How can I make it faster?

I have attached the issue portion image.

Is there any way to solve the issue?

I think the issue in I2C_TransferHandling function, because its repeatedly call in loop. But no idea about how to solve this issue.

Issue section

void Display_Clear(void)
 {
  int i = 0;

  Write_inst_oled(SSD1306_SET_COLUMN_ADDR);
  Write_inst_oled(0);
  Write_inst_oled(127);

  Write_inst_oled(SSD1306_SET_PAGE_ADDR);
  Write_inst_oled(0);
  Write_inst_oled(7);

  I2C_TransferHandling(I2C1,(SlaveAddr<<1),1, I2C_Reload_Mode, I2C_Generate_Start_Write);
  while(I2C_GetFlagStatus(I2C1, I2C_FLAG_TXIS) == RESET);
  Display_SendByte(SSD1306_DATA_CONTINUE);
  delay_ms(1);

  for (i = 0; i < 1024; i++)  // Write Zeros to clear the display
  {
      I2C_TransferHandling(I2C1,0, 1, I2C_Reload_Mode, I2C_No_StartStop);
      while(I2C_GetFlagStatus(I2C1, I2C_FLAG_TXIS) == RESET);
      Display_SendByte(0);
      delay_ms(1);
  }
    
  I2C_TransferHandling(I2C1, (SlaveAddr<<1), 0, I2C_SoftEnd_Mode, I2C_Generate_Start_Write);
    
  Write_inst_oled(SSD1306_SET_COLUMN_ADDR);
  Write_inst_oled(0);
  Write_inst_oled(127);

  Write_inst_oled(SSD1306_SET_PAGE_ADDR);
  Write_inst_oled(0);
  Write_inst_oled(7);

}

1 Answers1

0
  1. Remove delay from the loop. You wait 1ms on every iteration. It will save you more than 1 second,

  2. Increase the I2C speed. most displays support 400k+ I2C speeds. Sending 1024 bytes will take at least 0.8sek

0___________
  • 60,014
  • 4
  • 34
  • 74