STemwin GUI_Init Hard Fault

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

  • STemwin GUI_Init Hard Fault

    Hello. I use STemWin_Library_V1.1.2 (on EmWin 5.22). Processor STM32F103, IDE IAR EWARM 6.50. When executed GUI_Init() processor rush out in HardFault_Handler(). I found in debugging mode, what it happened when executed assembler command BLX R1 (R1=0x08004C30), or the memory address on jupm command out of processor FLASH regions. But sometimes in debugging mode GUI_Init() execute, and after GUI work OK. Change project option, stack size, GUI memory not helped. Programm still non-forking. What is the problem may be? Thank you.
  • Hello,

    The display driver callback function is called with a command. Could you please tell me which one? Please note that implementing this function is user responsibility, so you will have to make sure the function works properly. For details on how to correctly modify the function LCD_X_DisplayDriver(), please refer to the section 32.6 ""Display drivers" -> "Display driver callback function" in the emWin user manual.

    Best regards,
    Adrian
  • int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
    int r;
    (void) LayerIndex;
    (void) pData;

    switch (Cmd)
    {
    case LCD_X_INITCONTROLLER:
    {
    _InitController();
    return 0;
    }
    default: r = -1;
    }
    return r;
    }
    This function called with Cmd=1, executing _InitController(), and routine return r=0. I sure the innitialization of controller done correct.

    The post was edited 1 time, last by lehacheb ().

  • Hello,

    Are the functions LCD_X_Config() and GUI_X_Config() processed properly?

    Please note that the function LCD_X_Config() has to create an emWin display driver device and the function GUI_X_Config() needs to assign a sufficient amount of memory to emWin.

    Which driver do you use? In case you use GUIDRV_Lin, please make sure not to use the same memory area for both, GUI memory and frame buffer.

    Best regards,
    Adrian
  • #define XSIZE_PHYS 480// Physical display size
    #define YSIZE_PHYS 272
    #define COLOR_CONVERSION GUICC_M565
    #define DISPLAY_DRIVER GUIDRV_FLEXCOLOR
    #define DISPLAY_ORIENTATION (0)

    void LCD_X_Config(void)
    {
    GUI_DEVICE * pDevice;
    CONFIG_FLEXCOLOR Config = {0};
    GUI_PORT_API PortAPI = {0};

    pDevice = GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);// Set display driver and color conversion
    LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);// Display driver configuration
    LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
    Config.Orientation = DISPLAY_ORIENTATION;// Orientation
    GUIDRV_FlexColor_Config(pDevice, &Config);
    PortAPI.pfWrite8_A0 = Write_Cmd;//запись команда
    PortAPI.pfWrite8_A1 = Write_Data;//запись данные
    PortAPI.pfWriteM8_A1 = Write_M_Data;//запись нескольких байт данных
    PortAPI.pfReadM8_A1 = Read_M_Data;//чтение нескольких байт данных
    GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66720, GUIDRV_FLEXCOLOR_M16C0B8);
    }

    #include "GUI.h"
    #define GUI_NUMBYTES (1024) * 50 // x KByte Define the available number of bytes available for the GUI
    U32 static extMem[GUI_NUMBYTES / 4];//32 bit aligned memory area

    void GUI_X_Config(void)
    {
    GUI_ALLOC_AssignMemory(extMem, GUI_NUMBYTES);
    GUI_SetDefaultFont(GUI_FONT_8X16);
    }

    I use GUIDRV_FLEXCOLOR
  • Lehacheb, i think you should use functions
    PortAPI.pfWrite16_A0 = LcdWriteReg;
    PortAPI.pfWrite16_A1 = LcdWriteData;
    PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
    PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
    I understand correctly you have 16 bits data bus?

    The post was edited 1 time, last by pvo125 ().

  • I have 8 bit data bus. Но это вроде бы как неважно, сами-то функции описаны правильно, потому что иногда инициализацию проходит и GUI загружает. Но все равно скинь пожалуйста, посмотрю
  • My functions in file LCDConf.c


    static __INLINE void LcdWriteReg(U16 Data) {
    // ... TBD by user
    LCD_REG_ADDRESS=Data;
    }
    static __INLINE void LcdWriteData(U16 Data) {
    // ... TBD by user
    LCD_DATA_ADDRESS=Data;
    }
    static __INLINE void LcdWriteDataMultiple(U16 * pData, int NumItems) {
    while (NumItems--) {
    // ... TBD by user
    LCD_DATA_ADDRESS = *pData++;
    }
    }

    static __INLINE void LcdReadDataMultiple(U16 * pData, int NumItems) {
    while (NumItems--) {
    // ... TBD by user
    *pData++ = LCD_DATA_ADDRESS;
    }
    }

    void LCD_X_Config(void) {
    // U32 TouchOrientation;
    GUI_DEVICE * pDevice;
    CONFIG_FLEXCOLOR Config = {0};
    GUI_PORT_API PortAPI = {0};
    //
    // Set display driver and color conversion
    //
    pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
    //
    // Display driver configuration, required for Lin-driver
    //
    LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
    LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);

    //
    // Display driver configuration, required for Lin-driver
    //
    Config.Orientation =GUI_MIRROR_Y|GUI_MIRROR_X;
    //Config.FirstCOM=0;
    //Config.FirstSEG=0;
    GUIDRV_FlexColor_Config(pDevice, &Config);
    //
    // Set controller and operation mode
    //
    //
    GUIDRV_FlexColor_SetReadFunc66720_B16(pDevice, GUIDRV_FLEXCOLOR_READ_FUNC_II); //GUIDRV_FLEXCOLOR_READ_FUNC_II
    PortAPI.pfWrite16_A0 = LcdWriteReg;
    PortAPI.pfWrite16_A1 = LcdWriteData;
    PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
    PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
    GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66720, GUIDRV_FLEXCOLOR_M16C0B16);
    }

    My version LCD_X_Config not much different from yours. You hardfault happens at what point (LCD_X_Config, LCD_X_DisplayDriver or in the wilds of the library in the disassembler?)

    The post was edited 1 time, last by pvo125 ().