S12zVl preserving RAM location during cop reset

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

S12zVl preserving RAM location during cop reset

450 Views
charudattaingal
Contributor IV

Hello Team,

we need to preserve one RAM location after COP reset.

please suggest, how we can achieve this in S12ZVL ?

Best Regards,

Charudatta

0 Kudos
1 Reply

379 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

The data sheet states:

1.12.3.4 RAM
The system RAM arrays, including their ECC syndromes, are initialized following a power on reset.
With the exception of a power-on-reset the RAM content is unaltered by a reset occurrence.

The only issue you have to solve is processing of the code after COP reset. If you use CodeWarriror which contains initialization  routines (for variables and constants) placed in the file start12.c.

The functions for initialization the RAM, constant , variables...placement is a module Start12z.c

pastedImage_2.png

If you do not want to use initialization routines then you must recognize COP reset after reset event (register)

  if (CPMURFLG_COPRF)
    {
       // COP reset has started the process
    }

Note, the function and modification must be a part of Start12z.c....original code in Start12z.c is:

(_Startup(void) is a function where POR, COP,.. reset vector points to.)

__EXTERN_C void _Startup(void) {
    __asm {
        LD S, #__SEG_END_SSTACK-1        /* initialize SP */
#ifdef __ALIGN_STACK_OPT__
        TFR S, D6                        /* align SP to 4*/
        AND D6, #-4
        TFR D6, S
#endif        
    }
    DoZeroOut();
    DoCopyDown();
#ifdef __cplusplus
    __static_init();
#endif
    main();
}

I would like to suggest you to check what DoZeroOut and DoCopyDown performs to be able to correctly place the condition "if (CPMURFLG_COPRF)".

Sometimes it is suitable to perform "TOTAL" modification of the fila Start12z.c if you want to have EVERYTHING under your control. In this case, however, you are then responsible for correct initialization of variables after POR.

Of course there is also another possibility which ensures no automatic access of CodeWarrior Initialization procedures to the RAM. The way is modificatin of the PRM file.

Modify RAM segment...split it to segment controlled by CW and segment not initialized.

pastedImage_16.png

and also Placement :

pastedImage_17.png

Then, In the main.c file I will use two different approaches to visualize performance :

pastedImage_10.png

note, I used static  and volatile qualifiers to avoid optimization process to exclude variables from the code.

After reset (stopped at the beginning/top of the main() function) I can see i, j, k as no initialized but ii, jj, kk are initialized after Start12z file processing.

pastedImage_9.png

If I step through:

void main(void)

  i = 11;   
  j = 12;
  k = 13;
  ii = 14;
  jj = 15;
  kk = 16;

... and now reset, then after execution of Start 12z.c and stopped at the beginning/top of the main() function I can see:

pastedImage_15.png

....soft reset has not changed content of i, j, k  (even I used initialization "static unsigned char volatile i=1,j=2,k=3;" but PLACEMENT to NO_INIT section has higher priority).

Result....ii, jj, kk are always modified and initialized after reset in the initialization function placed in the Start12z.c file. i,j,k are not modified because they are placed in the RAM_NO_INIT, my user space, which is not initialized after reset what was defined in the prm file by creating exttra RAM space for unitialized variables.

I have provided you two different approaches and now it is up to you which one is more suitable for you or you can use combination of both of them.

Best regards,

Ladislav

0 Kudos