TIPS: Keep a variable beetween Resets

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

TIPS: Keep a variable beetween Resets

1,838件の閲覧回数
RChapman
Contributor I
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
 
Posted: Fri Nov 18, 2005 12:05 pm    
 
Yo People,

Question If you always wondered how you could keep something in RAM which won't always be re-initialize when you start your code...
Well this is an answer !
Arrow You just need to declared a special area in your parameter file and the start-up softawre will not initialize this zone.
Idea It's quite neat if you want to keep a count of the number of resets.

Exclamation Exclamation But be careful as if you have a Low Voltage Reset or Power On Reset this value might be corrupted or may not be meaningful.

In the PRM file
Code:
SECTIONS
    RESET_COUNTER = NO_INIT 0x1EFF TO 0x1EFF;

Code:
PLACEMENT
    NON_INITIALISED         INTO EMC_RESET_COUNTER;   

And In the C code
Code:
/* global variables */
#pragma DATA_SEG NON_INITIALISED
unsigned char ResetCounter;
#pragma DATA_SEG DEFAULT


Enjoy,
Posted: Fri Nov 18, 2005 4:13 pm    
 
Shouldn't the PLACEMENT be

PLACEMENT
NON_INITIALISED INTO RESET_COUNTER;


instead of

PLACEMENT
NON_INITIALISED INTO EMC_RESET_COUNTER;

Posted: Fri Nov 18, 2005 4:20 pm    
 
is there an error in your PRM? I see a "EMC_RESET_COUNTER" and a "RESET_COUNTER". Are these supposed to be the same? Also, you don't have "DEFAULT" listed in your PRM, but I know what you mean.
 
Posted: Mon Nov 21, 2005 8:47 am    
 
Yes it should be without the prefix EMC_ on the second time.
I forgot to remove it when I did my copy/paste from my source code.
I did not paste the rest of the prm file (default...) because the prm file is too big for me to paste it in a post.

(bad copy/paste, bad...)
ラベル(1)
0 件の賞賛
返信
0 返答(返信)