Hi Brendon,
I looked at your examples and I could not see any usage of external Ram in both 2 bpp and 16 bpp projects. My project is emwin_touch_and_draw from SDK_2_3_0_LpcXpresso_54608. I modified it a bit as you see below. I used timer etc. and I modified the pin_mux.c file to use sdram and emwin library at the same time.
as you see I add there a header file " #include "cr_section_macros.h" " to use this macro : __attribute__(( section(".noinit.$RAM4"), aligned(8) ))
my sdram is fourth one. when I make a new buffer and use it in 'int main()' I can see that I use an external sdram. That is okay. But I could not find framebuffer for emwin library. If I find it I can move lots of my datas to external ram.
I have tried one more thing. I made my external ram's priority first from Project>Properties>C/C++ Build/MCU Settings.

I changed its location with SRAM_0_1_2_3's location. I added its driver. when I compiled it there was no error and all datas was looked in BOARD_SDRAM.

But when I debug it, It gave an error as expected. Error picture is here. I don't know what to do on this step.

/* Standard C Included Files */
#include <stdio.h>
#include <string.h>
#include "board.h"
#include "fsl_debug_console.h"
#include "emwin_support.h"
#include "fsl_ctimer.h"
#include "GUI.h"
#include "GUIDRV_Lin.h"
#include "BUTTON.h"
#include "pin_mux.h"
#include "fsl_sctimer.h"
#include "fsl_emc.h"
#include "fsl_lcdc.h"
#include "fsl_i2c.h"
#include "fsl_ft5406.h"
#include "cr_section_macros.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define EXAMPLE_I2C_MASTER_BASE (I2C2_BASE)
#define I2C_MASTER_CLOCK_FREQUENCY (12000000)
#define SDRAM_BASE_ADDR 0xa0000000
#define SDRAM_SIZE_BYTES 8 * 1024 * 1024
#define APP_LCD LCD
#define APP_LCD_IRQHandler LCD_IRQHandler
#define APP_LCD_IRQn LCD_IRQn
#define LCD_PANEL_CLK 9000000
#define LCD_PPL 480
#define LCD_HSW 2
#define LCD_HFP 8
#define LCD_HBP 43
#define LCD_LPP 272
#define LCD_VSW 10
#define LCD_VFP 4
#define LCD_VBP 12
#define LCD_POL_FLAGS kLCDC_InvertVsyncPolarity | kLCDC_InvertHsyncPolarity
#define LCD_INPUT_CLK_FREQ CLOCK_GetFreq(kCLOCK_LCD)
#define LCD_WIDTH 480
#define LCD_HEIGHT 272
#define LCD_BITS_PER_PIXEL 16
/* Work memory for emWin */
#define GUI_NUMBYTES 0x20000
#define GUI_MEMORY_ADDR (SDRAM_BASE_ADDR)
/* Display framebuffer */
#define GUI_BUFFERS 2
#define VRAM_ADDR (GUI_MEMORY_ADDR + GUI_NUMBYTES)
#define VRAM_SIZE (LCD_HEIGHT * LCD_WIDTH * LCD_BITS_PER_PIXEL / 8)
#define CTIMER CTIMER3 /* Timer 3 */
#define CTIMER_MAT0_OUT kCTIMER_Match_0 /* Match output 0 */
#define CTIMER_MAT1_OUT kCTIMER_Match_1 /* Match output 1 */
#define BUS_CLK_FREQ CLOCK_GetFreq(kCLOCK_BusClk)
#define APP_BOARD_TEST_GPIO_PORT1 BOARD_LED3_GPIO_PORT
#define APP_BOARD_TEST_GPIO_PORT2 BOARD_LED1_GPIO_PORT
#define APP_BOARD_TEST_GPIO_PORT3 BOARD_LED2_GPIO_PORT
#define APP_BOARD_TEST_LED1_PIN BOARD_LED3_GPIO_PIN
#define APP_BOARD_TEST_LED2_PIN BOARD_LED1_GPIO_PIN
#define APP_BOARD_TEST_LED3_PIN BOARD_LED2_GPIO_PIN
#define APP_SW1_PORT BOARD_SW4_GPIO_PORT
#define APP_SW2_PORT BOARD_SW2_GPIO_PORT
#define APP_SW1_PIN BOARD_SW4_GPIO_PIN
#define APP_SW2_PIN BOARD_SW2_GPIO_PIN
/*******************************************************************************
* Prototypes
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/
/* Match Configuration for Channel 0 */
static ctimer_match_config_t matchConfig0;
/* Match Configuration for Channel 1 */
static ctimer_match_config_t matchConfig1;
#define CLEAR_BUTTON_ID (GUI_ID_BUTTON0)
#define COLOR_BUTTONS 8
#define COLOR_BUTTON_FIRST_ID (GUI_ID_USER)
#define COLOR_BUTTON_LAST_ID (COLOR_BUTTON_FIRST_ID + COLOR_BUTTONS - 1)
static GUI_COLOR button_color[COLOR_BUTTONS] = {GUI_WHITE, GUI_YELLOW, GUI_ORANGE, GUI_BLACK,
GUI_MAGENTA, GUI_BLUE, GUI_GREEN, GUI_RED};
void ctimer_match1_callback(uint32_t flags);
void ctimer_match0_callback(uint32_t flags);
/* Array of function pointers for callback for each channel */
ctimer_callback_t ctimer_callback_table[] = {
ctimer_match0_callback, ctimer_match1_callback, NULL, NULL, NULL, NULL, NULL, NULL};
/*******************************************************************************
* Code
******************************************************************************/
status_t SDRAM_DataBusCheck(volatile uint32_t *address)
{
uint32_t data = 0;
/* Write the walking 1's data test. */
for (data = 1; data != 0; data <<= 1)
{
*address = data;
/* Read the data out of the address and check. */
if (*address != data)
{
return kStatus_Fail;
}
}
return kStatus_Success;
}
status_t SDRAM_AddressBusCheck(volatile uint32_t *address, uint32_t bytes)
{
uint32_t pattern = 0x55555555;
uint32_t size = bytes / 4;
uint32_t offset;
uint32_t checkOffset;
/* write the pattern to the power-of-two address. */
for (offset = 1; offset < size; offset <<= 1)
{
address[offset] = pattern;
}
address[0] = ~pattern;
/* Read and check. */
for (offset = 1; offset < size; offset <<= 1)
{
if (address[offset] != pattern)
{
return kStatus_Fail;
}
}
if (address[0] != ~pattern)
{
return kStatus_Fail;
}
/* Change the data to the revert one address each time
* and check there is no effect to other address. */
for (offset = 1; offset < size; offset <<= 1)
{
address[offset] = ~pattern;
for (checkOffset = 1; checkOffset < size; checkOffset <<= 1)
{
if ((checkOffset != offset) && (address[checkOffset] != pattern))
{
return kStatus_Fail;
}
}
address[offset] = pattern;
}
return kStatus_Success;
}
void ctimer_match1_callback(uint32_t flags)
{
GPIO_TogglePinsOutput(GPIO, APP_BOARD_TEST_GPIO_PORT1, 1u << APP_BOARD_TEST_LED1_PIN);
Scheduled_Tasks();
}
void ctimer_match0_callback(uint32_t flags)
{
}
void BOARD_InitPWM(void)
{
sctimer_config_t config;
sctimer_pwm_signal_param_t pwmParam;
uint32_t event;
CLOCK_AttachClk(kMCLK_to_SCT_CLK);
CLOCK_SetClkDiv(kCLOCK_DivSctClk, 2, true);
SCTIMER_GetDefaultConfig(&config);
SCTIMER_Init(SCT0, &config);
pwmParam.output = kSCTIMER_Out_5;
pwmParam.level = kSCTIMER_HighTrue;
pwmParam.dutyCyclePercent = 5;
SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 1000U, CLOCK_GetFreq(kCLOCK_Sct), &event);
}
static void cbBackgroundWin(WM_MESSAGE *pMsg)
{
int widget_id;
switch (pMsg->MsgId)
{
case WM_NOTIFY_PARENT:
widget_id = WM_GetId(pMsg->hWinSrc);
if (widget_id >= COLOR_BUTTON_FIRST_ID && widget_id <= COLOR_BUTTON_LAST_ID)
{
GUI_SetColor(button_color[widget_id - COLOR_BUTTON_FIRST_ID]);
}
else if (widget_id == CLEAR_BUTTON_ID && pMsg->Data.v == WM_NOTIFICATION_CLICKED)
{
GUI_Clear();
}
break;
default:
WM_DefaultProc(pMsg);
}
}
void drawpixel (int x,int y,int color){
// GUI_SetColor (color);
// LCD_HL_DrawPixel(x, y);
char* adres;
int temp_color = 0;
temp_color = ((color & 0xf800) >> 11) | ((color & 0x001f) << 11) | ((color & 0x07e0)) ;
adres=VRAM_ADDR;
adres[(x + y*480)*2]=temp_color&0x000000ff;
adres[(x + y*480)*2+1]=(temp_color&0x0000ff00)>>8;
}
int main(void)
{
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput, 0,
};
ctimer_config_t config;
/* Board pin, clock, debug console init */
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
/* Route Main clock to LCD. */
CLOCK_AttachClk(kMCLK_to_LCD_CLK);
/* attach 12 MHz clock to FLEXCOMM2 (I2C master for touch controller) */
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
CLOCK_EnableClock(kCLOCK_Gpio2);
CLOCK_SetClkDiv(kCLOCK_DivLcdClk, 1, true);
BOARD_InitPins();
BOARD_BootClockFROHF96M();//BOARD_BootClockPLL220M();
BOARD_InitDebugConsole();
BOARD_InitSDRAM();
/* Set the back light PWM. */
BOARD_InitPWM();
CTIMER_GetDefaultConfig(&config);
CTIMER_Init(CTIMER, &config);
/* Configuration 0 */
matchConfig0.enableCounterReset = true;
matchConfig0.enableCounterStop = false;
matchConfig0.matchValue = BUS_CLK_FREQ / 10;
matchConfig0.outControl = kCTIMER_Output_Toggle;
matchConfig0.outPinInitState = false;
matchConfig0.enableInterrupt = true;
/* Configuration 1 */
matchConfig1.enableCounterReset = true;
matchConfig1.enableCounterStop = false;
matchConfig1.matchValue = BUS_CLK_FREQ / 1000;
matchConfig1.outControl = kCTIMER_Output_Toggle;
matchConfig1.outPinInitState = true;
matchConfig1.enableInterrupt = true;
CTIMER_RegisterCallBack(CTIMER, &ctimer_callback_table[0], kCTIMER_MultipleCallback);
CTIMER_SetupMatch(CTIMER, CTIMER_MAT0_OUT, &matchConfig0);
CTIMER_SetupMatch(CTIMER, CTIMER_MAT1_OUT, &matchConfig1);
CTIMER_StartTimer(CTIMER);
GPIO_PinInit(GPIO, APP_BOARD_TEST_GPIO_PORT1, APP_BOARD_TEST_LED1_PIN, &led_config);
GPIO_WritePinOutput(GPIO, APP_BOARD_TEST_GPIO_PORT1, APP_BOARD_TEST_LED1_PIN, 1);
/* emWin start */
GUI_Init();
/* Set size and default color for the background window */
WM_SetSize(WM_HBKWIN, LCD_WIDTH, LCD_HEIGHT);
WM_SetDesktopColor(GUI_BLUE);
/* Set callback for the backgroung window */
WM_SetCallback(WM_HBKWIN, cbBackgroundWin);
GUI_Clear();
Tasks();
}