I use CodeWarrior 10.6 with CPU MPC5604B (MPC560xB Qorriva) and I find an error on default source file when I create a project.
In the file MPC5604B_HWInit.c there is the function INIT_Derivative():
__asm void INIT_Derivative(void)
/* Disable WatchDog*/
// *(volatile unsigned int*)0xfff38010 = 0x0000c520;
// *(volatile unsigned int*) 0xfff38010 = 0x0000d928;
// *(volatile unsigned int*) 0xfff38000 = 0xff00000A;
/* SRAM initialization code*/
/* Loops to cover L2SRAM, stmw allows 128 bytes (32 GPRS x 4 bytes) writes */
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 48k of SRAM */
I set the important part of this function in bolt.
My problem is: the RAM is not initialized to value 0 by default.
Register r0 contains correctly value 0x00000000 (32 bits register) but there is other value write in all RAM memory.
But if I change the RAM access size from 128 to 4 bits the RAM is correctly initialized to value 0 as expected.
Where is the issue ? Bad initial source code or/and the ECU doesn't support 128 bits access ?
Thanks for your help.
There is no issue at all.
There in no need to have ram initialized with 0x0000 0000 patern.
And it is also not recommended to have all 0 in SRAM.
Your RAM will be initialed with R0 to R31 GPRs in 128bytes loops. And the address on R11 will be incremented by 128B.
I understand that there is no necessary to initialze the RAM with a specified pattern.
But for my application I initialize or not a part of the RAM depending of DES register of RGM peripheral (DES = 0, no initialization, otherwise done).
How, in this case, can I be sure that (I can't know in advance value of the word in this RAM part) my data have the expected value ?
For example I use 2 bool data and 1 counter. At startup if DES != 0 my 2 bool data and my counter are initialized with default function INIT_Derivative() and never modified between end of the function INIT_Derivative() and the call of my function in my application (I have add the option NO_INIT_BSS in linker to remove default value of these data from function __init_data() ). What is the risk that my bool data are not by accident corrupted and my counter is corrupted ? I can't afford to have this behaviour becuase this counter is used to enter in critical mode if its value is greater than a specified value.
What is the reason to avoid the initialization with 0x0000 0000 pattern ?
Thanks for your help,