GUI_Init() Infinite Loop

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

    • GUI_Init() Infinite Loop

      Hello,

      I made a custom board using the stm32f407 microcontroller, a 480x272 tft display with the SSD1963 controller, and an external sram chip IS61WV102416BLL.
      Without emWin,
      - I confirmed that I can display an image on the display
      - Write and read back 32-bit data to and from the sram

      The problem is, I am trying to use emWin for the first time with embOS, and I get stuck in an infinite loop after calling GUI_Init(). Using the debugger I found out that I am stuck in an interrupt handler (CAN1_RX1_IRQHandler) after GUIDRV_FlexColor_SetMode16bppC1B16() is called.

      I am not really sure which direction to take to debug this issue. Nowhere in my code do I explicitly enable interrupts (so nothing related to the CAN bus).
      Any help would be appreciated.
      Please let me know if there is any question, thank you.

      main.c

      C Source Code

      1. static OS_STACKPTR int stack_display[768]; /* Task stack */
      2. static OS_TASK tcb_display; /* Task-control-block */
      3. int main(void)
      4. {
      5. OS_Init(); // Initialize embOS
      6. OS_InitHW(); // Initialize required hardware
      7. BSP_Init(); // Initialize LED ports
      8. OS_CREATETASK(&tcb_display, "maintask_display", maintask_display, 100, stack_display);
      9. OS_Start(); // Start embOS
      10. return 0;
      11. }
      Display All



      LCDConf.c

      C Source Code

      1. /*********************************************************************
      2. *
      3. * LCD_X_Config
      4. *
      5. * Function description:
      6. * Called during the initialization process in order to set up the
      7. * display driver configuration.
      8. *
      9. */
      10. void LCD_X_Config(void)
      11. {
      12. GUI_DEVICE * pDevice;
      13. CONFIG_FLEXCOLOR pConfig = { 0, 0, 0, 0, -1 };
      14. GUI_PORT_API PortAPI = {0};
      15. //
      16. // Set display driver and color conversion
      17. //
      18. pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
      19. //
      20. // Configure driver's orientation
      21. //
      22. pConfig.Orientation = GUI_MIRROR_X;
      23. // pConfig.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
      24. GUIDRV_FlexColor_Config(pDevice, &pConfig);
      25. //
      26. // Display driver configuration, required for Lin-driver
      27. //
      28. LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
      29. LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
      30. //
      31. // Set controller and operation mode
      32. //
      33. PortAPI.pfWrite16_A0 = ssd1963_WriteReg;
      34. PortAPI.pfWrite16_A1 = ssd1963_WriteData;
      35. PortAPI.pfWriteM16_A1 = ssd1963_WriteDataMultiple;
      36. PortAPI.pfRead16_A1 = ssd1963_ReadData;
      37. PortAPI.pfReadM16_A1 = ssd1963_ReadDataMultiple;
      38. // GUIDRV_FlexColor_SetReadFunc66720_B16(pDevice, GUIDRV_FLEXCOLOR_READ_FUNC_II);
      39. GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66720, GUIDRV_FLEXCOLOR_M16C1B16);
      40. }
      41. /*********************************************************************
      42. *
      43. * LCD_X_DisplayDriver
      44. *
      45. * Function description:
      46. * This function is called by the display driver for several purposes.
      47. * To support the according task the routine needs to be adapted to
      48. * the display controller. Please note that the commands marked with
      49. * 'optional' are not cogently required and should only be adapted if
      50. * the display controller supports these features.
      51. *
      52. * Parameter:
      53. * LayerIndex - Index of layer to be configured
      54. * Cmd - Please refer to the details in the switch statement below
      55. * pData - Pointer to a LCD_X_DATA structure
      56. *
      57. * Return Value:
      58. * < -1 - Error
      59. * -1 - Command not handled
      60. * 0 - Ok
      61. */
      62. int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)
      63. {
      64. int r;
      65. (void) LayerIndex;
      66. (void) pData;
      67. switch (Cmd)
      68. {
      69. case LCD_X_INITCONTROLLER:
      70. {
      71. ssd1963_Init();
      72. return 0;
      73. }
      74. default:
      75. r = -1;
      76. }
      77. return r;
      78. }
      Display All

      GUIConf.c

      C Source Code

      1. #include "GUI.h"
      2. #include "BSP_GUI.h"
      3. #include "PIDConf.h"
      4. /*********************************************************************
      5. *
      6. * Defines
      7. *
      8. **********************************************************************
      9. */
      10. //
      11. // Define the available number of bytes available for the GUI
      12. //
      13. #define GUI_NUMBYTES 0x400
      14. #if (defined __ICCARM__) // IAR
      15. static __no_init U32 aMemory[GUI_NUMBYTES / 4] @ ".GUI_RAM";
      16. #elif (defined __SES_ARM) // SES
      17. static U32 aMemory[GUI_NUMBYTES / 4] __attribute__ ((section (".GUI_RAM")));
      18. #else
      19. static U32 aMemory[GUI_NUMBYTES / 4];
      20. #endif
      21. /*********************************************************************
      22. *
      23. * Static code
      24. *
      25. **********************************************************************
      26. */
      27. /*********************************************************************
      28. *
      29. * Public code
      30. *
      31. **********************************************************************
      32. */
      33. /*********************************************************************
      34. *
      35. * GUI_X_Config
      36. *
      37. * Purpose:
      38. * Called during the initialization process in order to set up the
      39. * available memory for the GUI.
      40. */
      41. void GUI_X_Config(void)
      42. {
      43. //
      44. // Assign memory to emWin
      45. //
      46. GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
      47. //
      48. // Set default font
      49. //
      50. GUI_SetDefaultFont(GUI_FONT_6X8);
      51. //
      52. // Init touch
      53. //
      54. //#ifndef _WINDOWS
      55. // GUI_PID_SetInitFunc(PID_X_Init);
      56. //#endif
      57. }
      Display All

      And .GUI_RAM lives in the SRAM.

      HTML Source Code

      1. <MemorySegment name="$(ExtSRAM_NAME:ExtSRAM)" >
      2. <ProgramSection alignment="4" load="No" name=".GUI_RAM" />
      3. </MemorySegment>




      Project specs:
      Environment: Segger Embedded Studio
      Microcontroller: stm32f407
      Display driver: SSD1963
      SRAM: IS61WV102416BLL
      Heap Size: 1024 Bytes
      Main Stack Size: 1024 Bytes
      Process Stack Size: 0 Bytes
    • Hi,

      emWin doesn't make use of hardware specific code. The only file where hardware gets initialised is LCDConf.c. Any other parts of emWin are completely independent of any hardware.

      You are calling ssd1963_Init() and other ssd1963 related functions. Maybe there is something inside which initializes a interrupt.

      Regards,
      Sven
    • SEGGER - Schoenen wrote:

      Hi,

      emWin doesn't make use of hardware specific code. The only file where hardware gets initialised is LCDConf.c. Any other parts of emWin are completely independent of any hardware.

      You are calling ssd1963_Init() and other ssd1963 related functions. Maybe there is something inside which initializes a interrupt.

      Regards,
      Sven
      The infinite loop happens before ssd1963_Init() is even called.
      It seems to occur right after GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66720, GUIDRV_FLEXCOLOR_M16C1B16) is called according to the call stack.

      I tried calling __disable_irq() before calling GUI_Init() in case something else was turning on that interrupt but no luck.