AnsweredAssumed Answered

LPCXpresso54608 Frame Buffer on SDRAM

Question asked by Victor Pecanins on Apr 19, 2017
Latest reply on Apr 20, 2017 by Victor Pecanins

I am interested on drawing in the LCD screen using direct writes in the framebuffer (no emWin, TouchGFX libraries whatsoever, just using MCUXpresso and fsl_lcdc driver. The project is based on the SDK demo project lpcxpresso54608_demo_apps_touch_cursor


I want to draw graphics with a greater color depth. For example, 24 bits per pixel. In order to do this, I need to allocate a bigger frame buffer, which does not fit in the internal RAM of the LPC54608. Therefore I want to allocate the frame buffer on the external SDRAM on the eval board. Can I have any example code for this?


So far, I tried using a macro declaration to allocate the buffer variable on the RAM4 region (which corresponds to the external RAM):


#include <cr_section_macros.h>


__attribute__(( section(".data.$RAM4"), aligned(8) ))

static uint8_t s_frameBufs[IMG_HEIGHT][IMG_WIDTH];


In addition to that, I added the functions necessary to bring up the external SDRAM from the example lpcxpresso54608_driver_examples_emc_sdram:


#include "fsl_emc.h"




My project builds correctly and the compiler statistics show indeed the variable is stored in the external RAM:


Memory region         Used Size  Region Size  %age Used

   PROGRAM_FLASH:       92532 B       512 KB     17.65%

     BOARD_FLASH:          0 GB        16 MB      0.00%

    SRAM_0_1_2_3:        8576 B       160 KB      5.23%

           SRAMX:          0 GB        32 KB      0.00%

         USB_RAM:          0 GB         8 KB      0.00%

     BOARD_SDRAM:       65280 B        16 MB      0.39%

Finished building target: lpcxpresso54608_demo_apps_touch_cursor.axf


However, it does not run after programming, the display on the eval board is completely white and, shockingly: The debugger hangs, it gives communication error and the board must be power cycled.



I think this application could be useful in many cases, an I am looking forward to know if there’s any example or application note explaining how to put the frame buffer on the external SDRAM.