Problems getting started with STemWin and ST7735 over FlexColor

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Problems getting started with STemWin and ST7735 over FlexColor

      Hello,

      i have ran in a problem while getting started with the STM32F446ZE and the STemWin Library. :(
      The used OS is embOS from your company.
      I tried to follow you instructions to display "hello world" on the display.
      I use the display driver ST7735S which should be supported by the FlexColor driver.

      My problem is that instead of "hello world" the display stays white.

      I configured GUIConf.h like that

      C Source Code

      1. #define GUI_NUMBYTES 0x8000
      In GUI_x I added the following in GUI_X_init() :

      C Source Code

      1. void GUI_X_Init(void) {
      2. UC_ST7735_init();
      3. USInt current = Sopas_usiGet_IOLink14360ST7735DisplayBacklightCurrent();
      4. LITA_setDisplayCurrent((uint8_t)current);
      5. }

      In UC_ST7735_init() the SPI-Port gets intiated. This part should work because it ist already used in the same sensor type. The only difference is, that I removed the graphcis library we used before. The addition lines activate the display and it's backlight.

      In LCDConf_FlexColor_Template.c I set the resolution like this:

      C Source Code

      1. #define XSIZE_PHYS 100 // To be adapted to x-screen size
      2. #define YSIZE_PHYS 40 // To be adapted to y-screen size

      The follwing three methods I filled like that:
      It should be metioned that UC_ST7735_writeSPI4Wire was also used before and should work. It sends one byte after each other instead of 16 bit at once.
      I tried to send the high byte and the low byte in different orders.

      C Source Code

      1. static void LcdWriteReg(U16 Data) {
      2. uint8_t data[2];
      3. UC_ST7735_dcFLAG_t dcFlag = UC_ST7735_COMMAND;
      4. data[0] = (uint8_t)UTIL_HLP_LOW_BYTE_OF_INT16(Data);
      5. data[1] = (uint8_t)UTIL_HLP_HIGH_BYTE_OF_INT16(Data);
      6. UC_ST7735_writeSPI4Wire(&data[1], 1, dcFlag);
      7. UC_ST7735_writeSPI4Wire(&data[0], 1, dcFlag);
      8. }
      9. static void LcdWriteData(U16 Data) {
      10. UC_ST7735_dcFLAG_t dcFlag = UC_ST7735_DATA;
      11. uint8_t data[2];
      12. data[0] = (uint8_t)UTIL_HLP_LOW_BYTE_OF_INT16(Data);
      13. data[1] = (uint8_t)UTIL_HLP_HIGH_BYTE_OF_INT16(Data);
      14. UC_ST7735_writeSPI4Wire(&data[1], 1, dcFlag);
      15. UC_ST7735_writeSPI4Wire(&data[0], 1, dcFlag);
      16. }
      17. static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
      18. UC_ST7735_dcFLAG_t dcFlag = UC_ST7735_DATA;
      19. uint8_t data[2];
      20. int start_size = NumItems;
      21. while (NumItems--) {
      22. data[0] = (uint8_t)UTIL_HLP_LOW_BYTE_OF_INT16(pData[start_size-NumItems]);
      23. data[1] = (uint8_t)UTIL_HLP_HIGH_BYTE_OF_INT16(pData[start_size-NumItems]);
      24. UC_ST7735_writeSPI4Wire(&data[1], 1, dcFlag);
      25. UC_ST7735_writeSPI4Wire(&data[0], 1, dcFlag);
      26. }
      27. }
      Display All

      I didn't change LCD_X_Config()

      C Source Code

      1. void LCD_X_Config(void) {
      2. GUI_DEVICE * pDevice;
      3. CONFIG_FLEXCOLOR Config = {0};
      4. GUI_PORT_API PortAPI = {0};
      5. //
      6. // Set display driver and color conversion
      7. //
      8. pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
      9. //
      10. // Display driver configuration, required for Lin-driver
      11. //
      12. LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
      13. LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
      14. //
      15. // Orientation
      16. //
      17. Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
      18. GUIDRV_FlexColor_Config(pDevice, &Config);
      19. //
      20. // Set controller and operation mode
      21. //
      22. PortAPI.pfWrite16_A0 = LcdWriteReg;
      23. PortAPI.pfWrite16_A1 = LcdWriteData;
      24. PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
      25. PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
      26. GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);
      27. }
      Display All


      The code I run is:

      Source Code

      1. GUI_Init();
      2. int xPos, yPos;
      3. //__HAL_RCC_CRC_CLK_ENABLE();
      4. xPos = LCD_GetXSize() / 2;
      5. yPos = LCD_GetYSize() / 3;
      6. GUI_SetFont(GUI_FONT_COMIC24B_ASCII);
      7. GUI_DispStringHCenterAt("Hello world!", xPos, yPos);
      8. // Endless loop:
      9. while(true)
      10. {
      11. OS_TASK_Delay(100);
      12. MW_TWD_arm(); // Arm the watchdog
      13. }
      Display All

      There is no Compile-Error and the Watch Dog does not cause a problem.
      The problem is that the display stays white.
      I noticed that the command number which the flexchain driver sends over spi does not match the excpeted numbers from the St7735 datasheet.
      I debugged the SPI method. The follwing commands and data got sent.
      - a command with 0x00 as the high byte
      - a command with 0x03 as the low byte. As far I know there is no command number 3 for theSTt7735
      - data with 0x00 as the high byte
      - data with 0x00 as the low byte
      - a command with 0x00 as the high byte
      - a command with 0x50 ('P') as the low byte.
      - data with 0x00 as the high byte
      - data with 0x00 as the low byte
      - a command with 0x00 as the high byte
      - a command with 0x51 ('Q') as the low byte.
      - data with 0x00 as the high byte
      - data with 0x63 as the low byte
      - a command with 0x00 as the high byte
      - a command with 0x52 as the low byte.
      - data with 0x00 as the high byte
      - data with 0x00 as the low byte
      ...
      - after a while with more alternating commands and data there is just data with 0x00
      Did I forget to config something?

      Mit freundlichen Grüßen / Best regards

      Lukas Hauser :)

      The post was edited 2 times, last by lukas.hauser ().

    • Changing GUIDRV_FLEXCOLOR_F66708 to GUIDRV_FLEXCOLOR_F667089 helped in order to get the right command numbers for the ST7735 display driver.

      Changing GUIDRV_FLEXCOLOR_M16C0B16 to GUIDRV_FLEXCOLOR_M16C1B8 doesn't. My device reboots before any SPI communication happens.
      I debugged the program to known when The error occurs.
      I runs the following methods without crashing but after the last one I didn't see an other name of a method in the disassmbly window of Keil.

      emwin_LCD_init
      LCD_SETBk_ColorIndex
      LCD_set_ClipRectMax
      GUI_Alloc_getFixedBlock
      GUI_Device_GetpDriver
      GUIDRV_Flexcolor_InitOnce
      GUI_Alloc_getFixedBlock

      LCD_X_DisplayDriver

      It get's to the end of LCD_X_DisplayDriver but never to LcdWriteReg, LcdWriteData, LcdWriteDataMultiple or LcdReadDataMultiple.

      What could be the problem? It's hard to debug without having the code.
    • Changing the default to this solved the problem:

      Source Code

      1. // Set controller and operation mode
      2. //
      3. PortAPI.pfWrite8_A0 = LcdWriteReg;
      4. PortAPI.pfWrite8_A1 = LcdWriteData;
      5. PortAPI.pfWriteM8_A1 = LcdWriteDataMultiple;
      6. // PortAPI.pfRead8_A1 = LcdReadData;
      7. // PortAPI.pfReadM8_A1 = LcdReadDataMultiple;