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"
...
BOARD_InitSDRAM();
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.
Thanks,
Víctor
解決済! 解決策の投稿を見る。
I solved the problem by myself. Thanks Dieter, your comment gave me the right clues. The LPC platform is very new for me and I was missing setting the proper configuration of the pins in the file board/pin_mux.c. The pin_mux.c files from SDK example projects must be combined in a single one to enable both LCD and SDRAM (lpcxpresso54608_demo_apps_touch_cursor and lpcxpresso54608_driver_examples_emc_sdram)
In addition to this, the variable storing the frame buffer must not be initialized (noinit section):
#include <cr_section_macros.h>
...
__attribute__(( section(".noinit.$RAM4"), aligned(8) ))
static uint8_t s_frameBufs[IMG_HEIGHT][IMG_WIDTH];
With this and calling the BOARD_InitSDRAM(); function, I am now able to put the frame buffer on the external SDRAM.
Best Regards,
Victor
I have the same results, but the Programm ist executing because I have one LED flashing via systick Int
in the main While loop.
The code for using the framebuffer is :
__attribute__ ((aligned(8), section(".noinit.$RAM4"))) uint8_t s_frameBuf0[IMG_HEIGHT][IMG_WIDTH / 4];
__attribute__ ((aligned(8), section(".noinit.$RAM4"))) uint8_t s_frameBuf1[IMG_HEIGHT][IMG_WIDTH / 4];
static const uint32_t s_frameBufAddr[] = {(uint32_t)s_frameBuf0, (uint32_t)s_frameBuf1};
static const uint32_t palette[] = {0x001F0000U, 0x7C0003D0U };
There is also an error in the PWM Routine for the display
pwmParam.level = kSCTIMER_LowTrue;
the example had HighTrue and you need the init for the output Pin
const uint32_t port3_pin31_config = (
IOCON_PIO_FUNC2 |
IOCON_PIO_MODE_INACT |
IOCON_PIO_INV_DI |
IOCON_PIO_DIGITAL_EN |
IOCON_PIO_INPFILT_OFF |
IOCON_PIO_SLEW_STANDARD |
IOCON_PIO_OPENDRAIN_DI
);
IOCON_PinMuxSet(IOCON, PORT3_IDX, PIN31_IDX, port3_pin31_config);
The Programm works without any problem if the framebuffer is allocated in SRAM
Thanks,
Dieter
I solved the problem by myself. Thanks Dieter, your comment gave me the right clues. The LPC platform is very new for me and I was missing setting the proper configuration of the pins in the file board/pin_mux.c. The pin_mux.c files from SDK example projects must be combined in a single one to enable both LCD and SDRAM (lpcxpresso54608_demo_apps_touch_cursor and lpcxpresso54608_driver_examples_emc_sdram)
In addition to this, the variable storing the frame buffer must not be initialized (noinit section):
#include <cr_section_macros.h>
...
__attribute__(( section(".noinit.$RAM4"), aligned(8) ))
static uint8_t s_frameBufs[IMG_HEIGHT][IMG_WIDTH];
With this and calling the BOARD_InitSDRAM(); function, I am now able to put the frame buffer on the external SDRAM.
Best Regards,
Victor