use of global variables with MPC5643L, CW10.5

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

use of global variables with MPC5643L, CW10.5

Jump to solution
3,289 Views
flofa
Contributor II

Hello everybody!

 

I am working on the MPC5643L using the tools RAPPID and CW10.5.

(development environment: XPC56xx EVB Motherboard Rev. C with XPC563xL 144LQFP MINI-MODULE equipped with µC PPC5643L)

 

I have a problem with the use of global variables in my project. Running in debugger works fine. Stop debugging and do a power reset the µC does not start running.

It seems the µC starts working doing e. g. the initilazation of the ports for LEDs and then corrupts.

 

Here is my source code: (µC is configured for DPM)

 

LL_var.c:   

#include "mpc5643l.h"

#include "kts\LL_var.h"

uint32_t dummy1 = 100;

uint32_t dummy2 = 200;

 

LL_var.h:

#ifndef LL_VAR_H_

#define LL_VAR_H_

extern uint32_t dummy1;

extern uint32_t dummy2;

#endif


main_p0.c:

...

while(1)

   {

    // fa

    dummy1 = 0x12345678;

    dummy2 = 0x87654321;   

    // fa

   }

 

If i just do "dummy1 = 0x12345678;" in while(1) (dummy2 commented out) it works fine with or without debugger.


if i define dummy1&2 as uint8 or unit16 it works fine with or without debugger.


Does anybody know this behaviour and can help me?




 

Nachricht geändert durch Florian Farrenkopf: update

Labels (1)
1 Solution
2,747 Views
stanish
NXP Employee
NXP Employee

Florian,

Please ignore my post with SRAM init code. RAppID init will generate SRAM initialization code if the correct option (ECC) is checked.

Enable this ECC RappID option for all the cores you are using. Also make sure "Generate Code For Flash" option is enabled. and regenerate the code.

RappID_Enable_ECC.png

If it does not help. Can you please also attach RappID init. project file (e.g. to the Service Request you've created)?

Thanks!

Stan

View solution in original post

0 Kudos
11 Replies
2,747 Views
stanish
NXP Employee
NXP Employee

Hello Florian,

Can you possibly post your .elf file or better entire project if possible?

I suspect there is a startup issue. It might be related to e.g. SRAM init but I'd need more info for analysis.

Thanks.

Stan

0 Kudos
2,747 Views
flofa
Contributor II

Hello Stan,

thanks for your answer.

I have attached my entire demo project.

Please contact me any time if you need further information.

I am looking forward for your analytics.

Thanks.

Florian

Von: Stanislav Sliva

Gesendet: Montag, 10. März 2014 18:45

An: Farrenkopf Florian

Betreff: Re: - use of global variables with MPC5643L, CW10.5

<https://community.freescale.com/>

use of global variables with MPC5643L, CW10.5

reply from Stanislav Sliva <https://community.freescale.com/people/stanish?et=watches.email.thread> in CodeWarrior for MCU - View the full discussion <https://community.freescale.com/message/386831?et=watches.email.thread#386831>

0 Kudos
2,747 Views
stanish
NXP Employee
NXP Employee

Hello Florian,

I've noticed the startup code (crt0_p0.s) does not include RAM ECC initialization routine.

If this routine is missing in debug - you don't see any problem since debugger script initializes the SRAM. But after a power on reset with no debugger connected an ECC exception might occur.

Can you possibly add the red code below into your crt0_p0.s rebuild the project and retest.

Please let me know if it helps.

Thanks!

Stan

__start:

  .include "initialize_gpr.inc"

  .include "crt0_include_p0.inc"

  e_lis      r1, __SP_INIT_z4_0@h ; Initialize stack pointer r1 to            

  e_or2i     r1, __SP_INIT_z4_0@l   ; value in linker command file.             

  e_lis      r13, _SDA_BASE_@h ; Initialize r13 to sdata base            

  e_or2i     r13, _SDA_BASE_@l ;             

  e_lis      r2, _SDA2_BASE_@h ; Initialize r2 to sdata2 base             

  e_or2i     r2, _SDA2_BASE_@l ; (provided by linker).            

  e_addi     r0,r0,0              ; Clear r0.            

  e_stwu     r1,-64(r1)           ; Terminate stack.            

  /* SRAM initialization code 0x4000_0000, size 0x10000 */

  e_lis r11, 0x4000@h

  /* Loops to cover L2SRAM, stmw allows 128 bytes (32 GPRS x 4 bytes) writes */

   e_lis r12, 0

   e_or2i r12, 512

start_init:

   mtctr r12

   init_l2sram_loop:

        e_stmw  r0, 0(r11)         /* Write 32 GPRs to SRAM*/

        e_add16i r11, r11, 128      /* Inc the ram ptr; 32 GPRs * 4 bytes = 128B */

        e_bdnz init_l2sram_loop     /* Loop for L2SRAM_CNT */

 

    /* in decoupled mode initialize the core_1 SRAM also 0x5000_0000, size 0x10000*/


    e_lis r12, 0x5000

    /* check if we already initialized L2SRAM_LOCATION_P1 */

    cmplw r11, r12

    se_bgt exit_sram_init

    e_lis r11, 0x5000

    //e_or2i r11, L2SRAM_LOCATION_P1@l

    e_lis r12, 0

    e_or2i r12, 512

    se_b start_init

    exit_sram_init:

#endif

0 Kudos
2,747 Views
yulianmatev
Contributor III

Hello Stanislav,

Could you please refer to a document where

   e_bdnz

instruction is described?

I already checked inside Variable-Length Encoding (VLE) Programming Environments Manual

but I was not able to find it there

Probably I found something: Variable-Length Encoding (VLE) Extension Programming Interface Manual

0 Kudos
2,747 Views
stanish
NXP Employee
NXP Employee

Yulian, 

e_bdnz is the instruction equivalent to e_bc 2,0,target ... Decrement CTR and branch if CTR ≠ 0

You can search "e_bdnz" in the VLE Extension Programming Interface Manual for more details:

http://www.nxp.com/assets/documents/data/en/supporting-information/VLEPIM.pdf 

hope it helps.

Stan

2,747 Views
flofa
Contributor II

Hello Stan,

thanks for your reply.

I integrated your code snippet into my DPM project. It does not work.

I attached my modified crt0_p0.s file. Have I included it correct?

(The new included code are the lines between my comments // fa ….SRAM init… // fa.)

Thanks,

Florian

edit: Also tried with LSM project. Does also not work.

Von: Stanislav Sliva

Gesendet: Montag, 17. März 2014 19:46

An: Farrenkopf Florian

Betreff: Re:  - Re: use of global variables with MPC5643L, CW10.5

  <https://community.freescale.com/>

Re: use of global variables with MPC5643L, CW10.5

reply from Stanislav Sliva <https://community.freescale.com/people/stanish?et=watches.email.thread>  in CodeWarrior for MCU - View the full discussion <https://community.freescale.com/message/388536?et=watches.email.thread#388536>

0 Kudos
2,748 Views
stanish
NXP Employee
NXP Employee

Florian,

Please ignore my post with SRAM init code. RAppID init will generate SRAM initialization code if the correct option (ECC) is checked.

Enable this ECC RappID option for all the cores you are using. Also make sure "Generate Code For Flash" option is enabled. and regenerate the code.

RappID_Enable_ECC.png

If it does not help. Can you please also attach RappID init. project file (e.g. to the Service Request you've created)?

Thanks!

Stan

0 Kudos
2,746 Views
flofa
Contributor II

Hey Stan,

thats it. This was the right hint.

I have tested it on both my LSM and DPM project and it works fine. :smileyhappy:

Just simple if you now what to do. :smileywink:

Thanks,

Florian

0 Kudos
2,746 Views
stanish
NXP Employee
NXP Employee

Florian,

Thanks for the update.

This will probably require some further analysis.

Can you possibly submit a new Service Request:  New Service Request

Thanks

Stan

0 Kudos
2,746 Views
flofa
Contributor II

Hello Stan,

ok. I will open a service request.

Thanks for your support.

Florian

0 Kudos
2,746 Views
flofa
Contributor II

In the mean time I have also built up a project in LS mode. Same behavior as DP mode.

0 Kudos