LPC54628 export function code into SDRAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC54628 export function code into SDRAM

900 Views
mateuszkiełbasa
Contributor III

Hi,

I would like to create some helpers function inside SDRAM on my LPC54628 board. I am working on "emc_sdram" example project and decorate desired function with __RAMFUNC(BOARD_SDRAM). I am able to compile the program with any errors and warnings. Also usage of sdram changes:

"BOARD_SDRAM:          32 B        16 MB      0.00%"

But after flashing everything is stucked and the program cannot acccess any breakpoint when debugging. SDRAM is initialized using example project. What should I do to run the function from sdram? Thanks for your answers!

Labels (1)
0 Kudos
3 Replies

749 Views
mateuszkiełbasa
Contributor III

Hi,

Thank for your answer.

I have read how to move function inside SDRAM using your link. This is main.c file contents:

#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_emc.h"
#include <stdbool.h>
#include "pin_mux.h"
#include "cr_section_macros.h"

__RAMFUNC(BOARD_SDRAM) void testSDRAM(void)
{
for (int i = 0; i < 10; i++) {
PRINTF("It works!\n");
}
}

int main(void)
{

/* Initialization inside SystemInitHook function */

testSDRAM();
EMC_Deinit(EMC);

while (1) {}
}

Also I moved all of the init function inside SystemInitHook function in systemLPC54628.c:

/* ----------------------------------------------------------------------------
-- SystemInitHook()
---------------------------------------------------------------------------- */

void SystemInitHook (void) {
/* Void implementation of the weak function. */
/* Hardware Initialization */
CLOCK_EnableClock(kCLOCK_InputMux);
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);

BOARD_InitPins();
BOARD_BootClockPLL220M();
BOARD_InitDebugConsole();
BOARD_InitSDRAM();
}

Now the program can reach first breakpoint inside main function but jumping into function code causes HardFault (MMSR) IACCVIOL.

I attached project structure. Could you provide any working "Hello world" example using attached project?

0 Kudos

749 Views
jeremyzhou
NXP Employee
NXP Employee

Hi

Thanks for your reply.
To provide the fastest possible support, I want to point you to a
similar question that has been answered on our NXP community.
Please refer to https://community.nxp.com/thread/471170
to view the details.
In further, I'd like to suggest you validate the SDRAM has already be initialized successfully via do some write and read operation to the SDRAM.

Have a great day.

TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

749 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Firstly, please follow the below post to place the specific functions into RAM blocks
https://community.nxp.com/thread/389099
Secondly, I'd like to point out that the SDRAM initialization should be finished prior to jump to the main() function if want to place the function in the SDRAM.

Have a great day.

TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos