general purpose gregisters  (mpc5744p)

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

general purpose gregisters  (mpc5744p)

Jump to solution
1,375 Views
xiaobozheng
Contributor III

deal all:

   

       is there any general purpose registers can keep the values , even soft reset ,the values still keep, not be changed. our program need keep some value in general registers, and then soft reset , after soft reset, we need this values to   know the last program state .

     thanks !

Labels (1)
1 Solution
1,147 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

Yes. You can use SPRGx or USPRGx core registers for this purpose.

Have in mind that their values sustain only trough short functional reset.

Peter

View solution in original post

5 Replies
1,148 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

Yes. You can use SPRGx or USPRGx core registers for this purpose.

Have in mind that their values sustain only trough short functional reset.

Peter

1,147 Views
xiaobozheng
Contributor III

but how we can use this USPRG0 register ?  can you give our an example?

0 Kudos
1,147 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

Software-use SPRs (SPRG0–SPRG7 and USPRG0), have no defined functionality. These
are shown below:
● SPRG0–SPRG2—can be accessed only in supervisor mode.
● SPRG3—can be written only in supervisor mode. It is readable in supervisor mode, but
whether it can be read in user mode is implementation-dependent.
● SPRG4–SPRG7—can be written only in supervisor mode; readable in supervisor or
user mode.
● USPRG0—can be accessed in supervisor or user mode.

pastedImage_1.png

Use mfspr and mtspr instructions to work with SPRs registers.

for details on how to work with SPR registers refer to z4 core RM:

http://cache.nxp.com/files/32bit/doc/ref_manual/e200z4RM.pdf?fsrch=1&sr=2&pageNum=1 

chapter:

4.4.8 Move To/From SPR Instruction Pipeline Operation

Peter

1,147 Views
xiaobozheng
Contributor III

HI,

      yes,   we can keep the value in  SPRG3,

   __asm("se_li r31,0x04 "); 
   __asm("mtspr SPRG3,r31");

  and also we can load the value,

  __asm("mfspr r30,SPRG3");

there is another problem , how can we  transfer R30 value to our  C variable,

for example:

register unsigned short   __res_stat;

how can we transfer R30 value to __res_stat?

0 Kudos
1,147 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

You know that this is compiler dependent.

Each compiler use different method for working with core SPR registers.

Read the compiler documentation or contact your compiler vendor.

Peter

0 Kudos