__attribute__ ((section(".text")))
int main(void)
{
int counter = 0;
short int your = 0;
I have add a declaration of "short int your = 0;" in the example "eTimer_MPC5744P" in S32DS.
I am using the newest S32DS 2017 R1 .
In debug model, it works well.
In debug_Ram model, it didn't work.
The Disassembly showed:
236 short int your = 0;
40002d00: se_li r7,0
40002d02: se_sth r7,12(r31)
And it failed at se_sth every time,and it show No source available kind of things.
So I wonder why?
Hello Jerry,
the problem is hidden in startup code. When you run example from flash, local DMEM is initialized by startup code. In this part of memory is placed stack, which is used for local variable storing.
But when you run example from RAM, this part of memory is not initialized because there is conditional compilation. When you try to write half word (short int) into uninitialized memory, ECC error is created.
Please use the following part of startup, instead of original one:
#ifdef START_FROM_FLASH
;#***************************** Initialise SRAM ECC ***************************/
;# Store number of 128Byte (32GPRs) segments in Counter
e_lis r5, __SRAM_SIZE@h # Initialize r5 to size of SRAM (Bytes)
e_or2i r5, __SRAM_SIZE@l
e_srwi r5, r5, 0x7 # Divide SRAM size by 128
mtctr r5 # Move to counter for use with "bdnz"
;# Base Address of the internal SRAM
e_lis r5, __SRAM_BASE_ADDR@h
e_or2i r5, __SRAM_BASE_ADDR@l
;# Fill SRAM with writes of 32GPRs
sram_loop:
e_stmw r0,0(r5) # Write all 32 registers to SRAM
e_addi r5,r5,128 # Increment the RAM pointer to next 128bytes
e_bdnz sram_loop # Loop for all of SRAM
#endif
;#************************ Initialise Local Data SRAM ECC *********************/
;# Store number of 128Byte (32GPRs) segments in Counter
e_lis r5, __LOCAL_DMEM_SIZE@h # Initialize r5 to size of SRAM (Bytes)
e_or2i r5, __LOCAL_DMEM_SIZE@l
e_srwi r5, r5, 0x7 # Divide SRAM size by 128
mtctr r5 # Move to counter for use with "bdnz"
;# Base Address of the Local SRAM
e_lis r5, __LOCAL_DMEM_BASE_ADDR@h
e_or2i r5, __LOCAL_DMEM_BASE_ADDR@l
;# Fill Local SRAM with writes of 32GPRs
ldmem_loop:
e_stmw r0,0(r5) # Write all 32 registers to SRAM
e_addi r5,r5,128 # Increment the RAM pointer to next 128bytes
e_bdnz ldmem_loop # Loop for all of SRAM
In original startup code, #endif is placed below ldmem_loop section.
Regards,
Martin
Thanks a lot for your help!