Having problems with memory

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

  • Having problems with memory


    I'm kind of new to using emWin. I'm developing an application on the Keil MCB4357 board. Here are some facts about my project.

    - The MCU is a NXP LPC4357
    - I have a SDRAM (16MBytes) connected to the EMC port (8-16-32 bits). Base address of the SDRAM is 0x28000000
    - I'm using the SDRAM for video buffering (at SDRAM base address)
    - I'm also using the SDRAM for calculation buffering (required by my application)
    - Code is not executed from SDRAM. It is only used by emWin and specific calculation buffers
    - I'm using the Lin driver (GUIDRV_LIN_16)
    - Color is GUICC_565
    - No touchscreen used
    - Display is 320*240
    - Using IAR Workbench ARM

    I'm using really the basics of emWin. Everything is disabled.
    #define GUI_NUM_LAYERS 1

    #define GUI_OS 0

    #define GUI_SUPPORT_TOUCH 0

    #define GUI_DEFAULT_FONT &GUI_Font6x8

    #define GUI_SUPPORT_MOUSE 0
    #define GUI_WINSUPPORT 0
    #define GUI_SUPPORT_MEMDEV 0

    My addresses looks like this:

    VRAM Addr
    At address: 0x28000000 (which is SDRAM base address)

    GUI Addr
    static U32* aMemory = (U32*)0x28100000;

    GUI_ALLOC_AssignMemory((U32*)aMemory, 0x200000);

    Calculation address
    At address: 0x28400000

    There are have 2 problems I observe.
    1- The same pixels do not behave normally. It's always the same pixels, but the way they behave is random. Let's say I draw a gray rectangle, 3 of the pixels (same column) will be black. On the next try, 1 will be black, the others will be ok. On the next, it's gonna be different.

    2- When I trigger my calculations, I see a lot of lines appear in my display, progressively. See attachment. Before, the screen was all black.

    Apart from those 2 problems, my application display the things correctly (logo in bmp, text, rectangles, etc.)

    Any idea of what can cause that?
    Thanks a lot, this is driving me crazy!
    • bug.jpg

      1.01 MB, 2,448×3,264, viewed 706 times
  • Ok some development. I moved the GUI buffer to internal RAM. It's size is now 0x2000. After testing, I get the exact same results. So, that removes the GUI buffer from the equation.

    How much RAM must I reserve for VRAM according to the way I use emWin (see original post)?
  • Hi,

    ok thanks for that, I'll use it.

    I also found my problem. It was not the buffering, but the SDRAM initialization. I got my hand on another MCB4357 and I was not getting any display errors. I noticed that the SDRAM chips on both boards were not exactly the same (not the same speed category). I was using an init function taken from a Keil example (can't remember which one) for the MCB4357, and I compared it with another Keil example (the emWin demo app) for the MCB4357 and noticed some differences. Trying the later resolved my problems.