lpcware

emWin gets stuck in GUI_Init

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Valametti on Wed May 27 05:02:07 MST 2015
I have a project for LPC1768 mbed platform that draws simple graphics into Sharp memory LCD using prebuild emWin library.

I exported the code from mbed online compiler and compiled it using using LPCXpresso. It works great, although first I had to play with library settings in order to get LPCXpresso to find the correct emWin library.

My company is using plain make and arm-none-eabi-g++. Therefore I exported the project also to GCC (Arm embedded). After getting the libraries right, the code compiles and runs, but gets stuck in GUI_Init().

Any idea what's wrong? I don't know if the code crashes or is in some infinite loop. The mbed lights don't blink.

Below, there are snippets of the emWin config files and main.cpp I have. They include some logging:

GUI_X.c:

#include "GUI.h"
#include "trace.h"

volatile GUI_TIMER_TIME OS_TimeMS;

void GUI_X_InitOS(void)    { /*OS_CreateRSema(&RSema);*/    }
void GUI_X_Unlock(void)    { /*OS_Unuse(&RSema);*/ }
void GUI_X_Lock(void)      { /*OS_Use(&RSema);*/  }
U32  GUI_X_GetTaskId(void) { return 0; /*(U32)OS_GetTaskID();*/ }


GUI_TIMER_TIME GUI_X_GetTime(void) {
    DEBUG("GUI_X_GetTime\r\n");
  return OS_TimeMS;
}

void GUI_X_Delay(int ms) {
    DEBUG("GUI_X_Delay %d\r\n", ms);
  int tEnd = OS_TimeMS + ms;
  while ((tEnd - OS_TimeMS) > 0);
}

void GUI_X_Init(void) { DEBUG("GUI_X_Init\r\n"); }

void GUI_X_ExecIdle(void) { DEBUG("GUI_X_ExecIdle\r\n");}

void GUI_X_Log     (const char *s) { DEBUG("Log: %s\r\n", s); }
void GUI_X_Warn    (const char *s) { DEBUG("Warn: %s\r\n", s); }
void GUI_X_ErrorOut(const char *s) { DEBUG("ErrorOut: %s\r\n", s); }


GUIConf.c:

#include <string.h>
#include <stdint.h>
#include "GUI.h"
#include "trace.h"

#define GUI_NUMBYTES  1024 * 4

#define GUI_BLOCKSIZE 0x128

void GUI_X_Config(void) {
    DEBUG("GUI_X_Config \r\n");
    static uint8_t aMemory[GUI_NUMBYTES];

    GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
    GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);

    GUI_SetDefaultFont(GUI_FONT_8X16);
}


LCDConf.c:

#include "GUI.h"
#include "GUIDRV_Lin.h"
#include "trace.h"

#define XSIZE_PHYS 416
#define YSIZE_PHYS 240

#define COLOR_CONVERSION GUICC_1

#define DISPLAY_DRIVER GUIDRV_LIN_1

void LCD_X_Config(void) {

    DEBUG("LCD_X_Config");

    GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);

    LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
    LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);

}

int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
    DEBUG("LCD_X_DisplayDriver layer: %x, cmd: %x, data %p\r\n", LayerIndex, Cmd, pData);
    switch (Cmd)
    {
        case LCD_X_INITCONTROLLER: {
          return 0;
        }
        default: {
          return -1;
        }
    }
}


main.cpp:

int main(void) {
...
    DEBUG("START\r\n");
...
    DEBUG("Entering GUI_Init\r\n");
    led4 = GUI_Init();
    DEBUG("Exited GUI_Init\r\n");


The output logs are as following:
LPCXpresso, Works OK:

START
Entering GUI_Init
Log:
     GUI_Init()
GUI_X_Config
LCD_X_ConfigLCD_X_DisplayDriver layer: 0, cmd: 7, data 0x10007b28
GUI_X_Init
Log:
     LCD_Init...
LCD_X_DisplayDriver layer: 0, cmd: 1, data 0x0
LCD_X_DisplayDriver layer: 0, cmd: 4, data 0x10007b08
LCD_X_DisplayDriver layer: 0, cmd: 4, data 0x10007b08
LCD_X_DisplayDriver layer: 0, cmd: 5, data 0x0
LCD_X_DisplayDriver layer: 0, cmd: 3, data 0x10007b38
Log:
     GUI_ALLOC_Alloc... requesting %d, %d avail 0x0000002C 0x00000838
Log:
     GUI_ALLOC_AllocNoInit... requesting %d, %d avail 0x0000002C 0x00000844
Log:
     GUI_ALLOC_AllocNoInit : Handle 0x00000002
Exited GUI_Init
LCD_X_DisplayDriver layer: 0, cmd: 2, data 0x10007b64


GCC Arm Embedded, gets stuck in GUI_Init()

START
Entering GUI_Init
Log:
     GUI_Init()
GUI_X_Config
LCD_X_ConfigLCD_X_DisplayDriver layer: 0, cmd: 7, data 0x10007b30
GUI_X_Init
Log:
     LCD_Init...
LCD_X_DisplayDriver layer: 0, cmd: 1, data 0
LCD_X_DisplayDriver layer: 0, cmd: 4, data 0x10007b10
LCD_X_DisplayDriver layer: 0, cmd: 4, data 0x10007b10

Outcomes