Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

meaninig of __attribute__((persistent)) in MPLAB

Status
Not open for further replies.

naderus

Member level 1
Joined
Sep 7, 2004
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
213
__attribute__ mplab

Hi,

what is the meaninig of __attribute__((persistent)) in MPLAB?
 

mplab __attribute__

Classically (persistent) data reamins the same across multipul program restarts.

Translating that to the use in MPLAB it would indicate that the data defined in persistant will remain constant despite issuing a MCU reset, looking at the documentation this seems to be the case

# persistent data is not normally initialized by the C run-time. However, from a cold-restart persistent data may not have any meaningful value. This code example shows how to safely initialize such data:

Code:
#include "p24Fxxxx.h"

int last_mode __attribute__((persistent));

int main()
{
    if ((RCONbits.POR == 0) &&
        (RCONbits.BOR == 0)) {
      /* last_mode is valid */
    } else {
      /* initialize presistent data */
      last_mode = 0;
    }
}

seems to support that, although they point out a cold power reset may well reset the value which is understandable, basicaly persistent means that so long as the MCU has power no reset command will clear that data, only a cold start will.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top