emWin - Some basic help

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

  • emWin - Some basic help

    Hi there,

    I think i lack some basic understanding of how to use emwin library and the underlying driver infrastructure.

    It would be much appreciated if you could help me understand the big picture here.

    My setup:
    I have an NXP LPC4367 mcu mounted on a custom PCB. This mcu has an lcd controller (i am not sure which is this controller. I think it is ST7565S).
    I also have a 2.4'' TFT Display Module DT024CTFT which has an ILI9341 lcd controller.

    What i want to do:
    Clearly i want to interface this external tft display with my mcu.

    Questions:
    1. There are 2 lcd controllers. Mcu has its own and display module also has its own.
    What controller needs to be configured? Both or choose which controller will do the job?

    2. I want to use segger emwin precompiled library for nxp mcus. Where can i find LCDConf files so that i can port examples of other targets to my own?

    Thanks a lot in advance
  • Hi,

    I guess the LCD is connected via a serial interface. In this case you don't need to initialize the MCUs LCD controller. Please take a look into the LCDConf.c attached. This LCDConf.c was written for an ILI9341 using an indirect interface and the GUIDRV_FlexColor driver.
    Of course it might be necessary to adapt some things in the LCDConf.c to fit to your environment.

    If your LCD is connected vie an RGB interface you would need to configure the LCD controller on your MCU and use the GUIDRV_Lin driver.
    2. I want to use segger emwin precompiled library for nxp mcus. Where
    can i find LCDConf files so that i can port examples of other targets to
    my own?
    Unfortunately I don't know the structure of the NXP projects. The last one of the NXP SDKs I was working with had no LCDConf.c. Any related functions where in the same file as main(). So it might be possible that you have to create your own by copy pasting the code from one file to another.

    Regards,
    Sven
    Files
    • LCDConf.zip

      (4.64 kB, downloaded 748 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Yes, configure the onboard LCD controller and tell the ili9341 how it receives the data (via RGB interface).

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Unfortunately I don't have a ready to use project.

    But I have attached a generic LCDConf.c to be used as a starting point when using the GUIDRV_Lin driver. Some functions need to be implemented on your own. For example a function to initialize the LCD controller.

    Also some value needs to be adapted to fit your environment. For example:

    Change these to fit your LCD size

    #define XSIZE_PHYS 320
    #define YSIZE_PHYS 240

    Change color conversion and the driver version

    #define COLOR_CONVERSION GUICC_8888 -> GUICC_565
    #define DISPLAY_DRIVER GUIDRV_LIN_32 -> GUIDRV_LIN_16

    Set the address of the framebuffer. This address needs to be passed to emWin and to the LCD controller

    #define VRAM_ADDR 0

    Regards,
    Sven
    Files
    • LCDConf.zip

      (1.84 kB, downloaded 578 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Thanks a lot for the previous help.

    I ve tried some things but hard fault exceptions occur.

    In my current setup i don't have an external sdram. So i am trying to fit emwin inside internal ram which is 32kb. Can i achieve that?
    From various examples i found out that it isn't required to set an external address.

    Inside LCDConf.c i don't set LCD_SetVRAMAddrEx(0, (void *)VRAM_ADDR)
    and in i just set static U32 aMemory to hold emwin inside internal ram?

    Is this the case?
  • Hi,

    32 KB is not that much. Although, it is possible. But do not expect a fancy application.

    The main issue will be to have some memory allocated for emWin besides the memory for the frame buffer. The frame buffer is required to use an indirect interface with the GUIDRV_Lin driver.

    Lets say you want to spend emWin 16 KB of memory you would have another 16 KB left. With a color depth of 16 bpp you would need 2 bytes per pixel. This means you can drive a display with 8,192 pixels (equals a size of ~90x90p).

    Since you are using the ILI9341 another possibility is to use a serial interface and the GUI_DRV_FlexColor driver. Using the GUIDRV_FlexColor will allow you to use the internal RAM of the ILI9341 and you can spend more memory for emWin.

    But even then you won't be able to use all features of emWin to their full extent (e.g. memory devices).

    Another issue might be that when using a pre-compiled library, it is not possible to switch off some modules of emWin, which are not required. So, you might loose the ability to save some additional bytes.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Great. I ll follow your suggestions and try this out.

    FYI I have a custom board with an LPC4367 and a display module that uses ili9341. I am waiting for an external sdram to come, so i ll freeze this setup for a while.

    Meanwhile i ll try to fix an adafruit 1.8 TFT with ST7735 controller (internal memory 384k) interfaced with an lpc4367 dev board.

    I will use serial spi interface, GUIDRV_FlexColor driver and take advantage the internal display memory (384k).

    So to make it clear my questions are:

    Inside lcdconf.c i don't have to set LCD_SetVRAMAddrEx. RIght? Does this mean the 384k memory will be in use because i m going to use serial interface for communcation?

    Inside GuiConf.c when i use GUI_ALLOC_AssignMemory what memory should i allocate?

    Sorry if my questions are kind of noobish! :)
  • Hi,

    I am waiting for an external sdram to come, so i ll freeze this setup for a while.
    Good decision ;) This will allow you to increase the emWin memory and have enough space for a frame buffer and other features like multibuffering or memory devices.
    Inside lcdconf.c i don't have to set LCD_SetVRAMAddrEx. RIght? Does this
    mean the 384k memory will be in use because i m going to use serial
    interface for communcation?
    Yes, you don't have to set a VRAM address. When something should be displayed we write via the serial interface into the RAM of the LCD controller.

    The only memory the GUIDRV_FlexColor driver needs is some to hold a configuration structure and some other memory to hold one line of display data.

    If you want to use the cache version of GUIDRV_FlexColor you need enough memory to hold one screen.
    Inside GuiConf.c when i use GUI_ALLOC_AssignMemory what memory should i allocate?
    Any memory which is available. Not sure what else is running on your device. But with only 32K you should give emWin as mouch as possible.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    After setting up st7735 1,8 TFT with lpc4367 dev board with flexcolor driver and spi communication I see on screen random dark color pixels.

    After debugging i noticed that code stucks at pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);

    It does not throw any kind of exception but it never moves beyond that point.

    Any help or idea?

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

  • Hi,

    How much memory do you have spend emWin in GUIConf.c?
    But at this time emWin needs only a few bytes to allocate memory for the device structure.

    Also you can try out what is going on when stepping through disassembly (I know this might get hard).

    Where does your program stays when you hold the executution?

    Regards
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Thanks again for the reply.

    I managed to overcome the silent crash at GUI_DEVICE_CreateAndLink but now i have a hardfault exception somewhere inside GUI_Init.

    I attach my configuration files in case you can make a suggestion etc.

    In my main function i do board initializations, a default timer is set and only GUI_Init() and GUI_SetBkColor(GUI_RED) are called.

    I am trying to debug code and LCDconf and guiconf don't cause any ecxeption.

    After exiting GUI_X_Init function inside GUI_X.c file which is unimplemented, program returns to GUI_Init() that lies in main and after a few seconds it crashes.

    In disassembly the last instruction i can see at debug is 1a001de1 (GUI_X_Init):

    1a001dd1: push {r3, r4, r5, lr}
    1a001dd3: bl 0x1a001da0 <GUI__Config>
    1a001dd7: ldr r5, [pc, #180] ; (0x1a001e8c <GUI_Init+188>)
    1a001dd9: ldr r3, [pc, #180] ; (0x1a001e90 <GUI_Init+192>)
    1a001ddb: ldr r4, [pc, #184] ; (0x1a001e94 <GUI_Init+196>)
    1a001ddd: movs r2, #46 ; 0x2e
    1a001ddf: strb r2, [r3, #0]
    1a001de1: bl 0x1a000298 <GUI_X_Init>
    1a001de5: ldr r3, [r5, #0]
    1a001de7: adds r2, r3, #4
    1a001de9: str r2, [r3, #60] ; 0x3c
    1a001deb: add.w r2, r3, #8
    1a001def: str r2, [r4, #20]
    1a001df1: ldrb r2, [r3, #17]
    1a001df3: str r3, [r3, #56] ; 0x38
    1a001df5: str r3, [r3, #64] ; 0x40
    1a001df7: ldr r3, [pc, #160] ; (0x1a001e98 <GUI_Init+200>)
    1a001df9: ldr.w r0, [r3, r2, lsl #2]
    1a001dfd: ldr r3, [r0, #12]
    1a001dff: add.w r1, r4, #8
    1a001e03: ldr r3, [r3, #48] ; 0x30
    1a001e05: blx r3
    1a001e07: ldr r3, [pc, #148] ; (0x1a001e9c <GUI_Init+204>)
    1a001e09: str r3, [r4, #96] ; 0x60
    1a001e0b: ldr r3, [pc, #148] ; (0x1a001ea0 <GUI_Init+208>)
    1a001e0d: ldr r3, [r3, #0]
    1a001e0f: str r3, [r4, #28]
    1a001e11: ldr r3, [r5, #0]
    1a001e13: adds r3, #8
    1a001e15: str r3, [r4, #20]
    1a001e17: movs r3, #1
    1a001e19: strb r3, [r4, #24]


    Question.
    Is it necessary to offer an implementation for both single and multiple PortAPI writes and reads?
    I only want to use PortAPI.pfWrite8_A0 and PortAPI.pfWrite8_A1.

    p.s.
    I did configure the ST7735 controller and set background colors when porting from an arduino adafruit library for my TFT.
    So spi part is good.
    Files
    • GUI_X.txt

      (4.46 kB, downloaded 629 times, last: )
    • GUIConf.txt

      (3.8 kB, downloaded 623 times, last: )
    • LCDConf.txt

      (8.14 kB, downloaded 736 times, last: )
    • LCD_X_SPI.txt

      (3.6 kB, downloaded 721 times, last: )
  • I have figured it out and now it is working!

    Thanks a lot for the help so far.

    I implemented also the multiple write functions pfWriteM8_A0 and pfWriteM8_A1 and now it works.

    I do see that some emwin functions don't work and others do.
    GUI_SetBkColor doesnt change the background color while GUI_DispDecAt works correctly.
  • Hi,

    With GUI_SetBkColor() you just set a back ground color. It doesn't do anything more. You have to call GUI_Clear() after setting a back ground color.

    Regards
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.