MPC5602P RAM variable occur unintended change when RAM size over 12K

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

MPC5602P RAM variable occur unintended change when RAM size over 12K

1,401 Views
NXP_Leo
Contributor II

Debug environment: CW11.1 and multilink universal FX

The value of variable which address is over 12K will change to be zero when software run.

The MCU ram size is 20K, i try to think that whether i need to fix some configuration in the CW11.1 to extend the ram size.

The ram configuration is as below in the lcf file:

/* SRAM: 0x40000000 - 0x40004FFF */
stack: org = 0x40000000, len = 0x00000BF0 /* Stack size = 3K - 0x10bytes */
stack_underflow_pattern:org = 0x40000BF0, len = 0x00000010
BootAppShare: org = 0x40000C00, len = 0x00000100
internal_ram: org = 0x40000D00, len = 0x00004300

 

0 Kudos
5 Replies

1,390 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

what about RAM initialization?

By default, the RAM is defined like this in the linker file:

internal_ram: org = 0x40000000, len = 0x00003000 /* 12K */
heap: org = 0x40003000, len = 0x00001000 /* 4K Heap */
stack: org = 0x40004000, len = 0x00001000 /* 4K Stack */

Then these numbers are used for RAM initialization (this can be also found in the linker file):

/* L2 SRAM Location (used for L2 SRAM initialization) */
L2SRAM_LOCATION = ADDR(internal_ram);

/* How many writes with stmw, 128 bytes each, are needed to cover
the whole L2SRAM (used for L2 SRAM initialization) */
L2SRAM_CNT = 0x5000 / 128;

 

The RAM is then initialized by this code in MPC5602P_HWInit.c:

/* SRAM initialization code*/
lis r11,L2SRAM_LOCATION@h
ori r11,r11,L2SRAM_LOCATION@l

/* Loops to cover L2SRAM, stmw allows 128 bytes (32 GPRS x 4 bytes) writes */
lis r12,L2SRAM_CNT@h
ori r12,r12,L2SRAM_CNT@l
mtctr r12

init_l2sram_loop:
stmw r0, 0(r11) /* Write 32 GPRs to SRAM*/
addi r11,r11,128 /* Inc the ram ptr; 32 GPRs * 4 bytes = 128B */
bdnz init_l2sram_loop /* Loop for L2SRAM_CNT times */

 

That means: if you moved your internal_ram segment to 0x40000D00, the RAM won't be initialized correctly. It's necessary to update L2SRAM_LOCATION  in the linker file.

Regards,

Lukas

0 Kudos

1,379 Views
NXP_Leo
Contributor II

More information about my lcf file:

/* Freescale CodeWarrior compiler address designations */
/* Stack location */
_stack_addr = ADDR(stack)+SIZEOF(stack);
_stack_end = ADDR(stack);
/*_stack_reset_addr = _stack_addr - 0x10;*/

/* Exceptions Handlers Location (used in Exceptions.c IVPR initialization)*/
EXCEPTION_HANDLERS = ADDR(exception_handlers);

/* L2 SRAM Location (used for L2 SRAM initialization) */
L2SRAM_LOCATION = 0x40000000;

FORCE_RESET_ENTRY = 0x00000004;

/* Application/Bootloader Shared RAM */
BOOT_APP_SHARED_ADDR = ADDR(BootAppShare);

/* Define the RAM section sizes */
INTERNAL_RAM_START_ADDR = ADDR(internal_ram);
INTERNAL_RAM_SIZE = SIZEOF(internal_ram);
STACK_SIZE = SIZEOF(stack);

/* Define RAM end addresses */
CLR_RAM_START_ADDR = ADDR(.bss);
CLR_RAM_END_ADDR = ADDR(internal_ram) + INTERNAL_RAM_SIZE;
CLR_CRASH_RAM_END_ADDR = ADDR(internal_ram) + INTERNAL_RAM_SIZE;

/* Cycle Number for RAM Initialization in INIT_Derivative() of MPC560xP_HWInit.c */
L2SRAM_CNT = (CLR_CRASH_RAM_END_ADDR - L2SRAM_LOCATION) / 128;

RAM initialization are some functions like below:

void LINMAPP_RamInit(void)
{
UNS8 i;
LINMAPP_GLOBAL.messageSequence = 0;
if (LINMAPP_ENABLE_NORMAL_TABLE)
{
LINMAPP_GLOBAL.tableIndex = NORMAL_TABLE;
}
else
{
LINMAPP_GLOBAL.tableIndex = DIAGNOSTIC_TABLE;
}

LINMAPP_GLOBAL.diagTableStatus = DIAG_TABLE_STOP;
for (i = 0; i < LINMAPP_COM_MESSAGE_NUM; i++)
{
LINMAPP_GLOBAL.messageDelayCounter[i] = LINMAPP_COM_SCHEDULE_TABLE[i].delay;
LINMAPP_ValveCtr.byte[]
}

for (i = 0; i < LINAPP_TESLA_VALVE_NUM; i++)
{
LINMAPP_GLOBAL.messageDelayCounter[i] = LINMAPP_COM_SCHEDULE_TABLE[i].delay;
LINMAPP_ValveCtr[i].byte = 0;
}

} /* End of LINMAPP_RamInit() */

0 Kudos

1,372 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Ok, if you have:

/* L2 SRAM Location (used for L2 SRAM initialization) */
L2SRAM_LOCATION = 0x40000000;

/* Cycle Number for RAM Initialization in INIT_Derivative() of MPC560xP_HWInit.c */
L2SRAM_CNT = (CLR_CRASH_RAM_END_ADDR - L2SRAM_LOCATION) / 128;

... then SRAM init shouldn't be the problem.

However, I do not have other suggestions, this would require some extensive debugging. Provided information is not enough...

Regards,

Lukas

0 Kudos

1,397 Views
NXP_Leo
Contributor II

When furtherly debug, i find the variable will be unintendedly changed to be the initialized value, then he data will be changed to the previous value automatically but when i set the breakpoint in the initialization code, i found the software never stop there except the first once, so i'm confused

The phenomenon above is always run .

0 Kudos

1,343 Views
NXP_Leo
Contributor II

This issue has been solved, but i'm not sure whether what i found is the root cause,

when i clear the tx complete flag after LIN1 send successfully, the RAM variable which belong to LIN1 module never change again.

0 Kudos