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 !
Solved! Go to Solution.
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
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
but how we can use this USPRG0 register ? can you give our an example?
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.
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
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?
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