This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FDS: Saving my records

NRF52 DK on SDK 12.2 (using armGCC)

I have the FDS example from GITHUB working - it shows it is writing and reading the example data (0xDEADBEEF and 0xBAADF00D) fine. I want to save my own data as a record instead of the data in the example and I need assistance. Below are the variables that I need to save so I can recover them after a power outage or reboot.

uint8_t		currentSetting;
int16_t		photocellThreshold;
uint16_t	pwmValue;
bool		powerState;
uint32_t	remoteMode1;
uint32_t	remoteMode2;
uint32_t	remoteMode3;

I am not sure if I should have a separate record for each variable or if I should write all as 1 "chunk" of data. Which is better?

My problem is how do I save those different data types into FDS?

How do I recover the settings after reboot?

Also, If the user changes the setting or PWM value for instace, I will use a timer and after 20 seconds of no setting changes, I will update the data to FDS. How can I update that changed information back into FDS?

Can someone assist me? I appreciate any help!

Thanks, Bryan

Parents
  • It would be better to save it as 1 chunk. Writing/Erasing is slow. It is done in background. So you wouldn't want to have to many of them. Also you cannot write to the same location of flash without erasing it first.

  • @Nguyen Hoan Hoang I looked throughout the infocenter and could find no other information for putting different data types into FDS.

    @Roger Clark

    Thank you for your answer. I am really green when it comes to C programming. Is this what I should be doing?:

    typedef struct
    {
    	uint8_t		currentSetting;
    	int16_t		photocellThreshold;
    	uint16_t	pwmValue;
    	bool		powerState;
    	uint32_t	remoteMode1;
    	uint32_t	remoteMode2;
    	uint32_t	remoteMode3;
    } myData;
    

    If this is correct, how do I assign variables to this struct? Then how do I put these into an acceptable format for "record_chunk.p_data"?

    I agree, having bool as 4 bytes should be no problem.

    Your patience and help is appreciated !!

Reply
  • @Nguyen Hoan Hoang I looked throughout the infocenter and could find no other information for putting different data types into FDS.

    @Roger Clark

    Thank you for your answer. I am really green when it comes to C programming. Is this what I should be doing?:

    typedef struct
    {
    	uint8_t		currentSetting;
    	int16_t		photocellThreshold;
    	uint16_t	pwmValue;
    	bool		powerState;
    	uint32_t	remoteMode1;
    	uint32_t	remoteMode2;
    	uint32_t	remoteMode3;
    } myData;
    

    If this is correct, how do I assign variables to this struct? Then how do I put these into an acceptable format for "record_chunk.p_data"?

    I agree, having bool as 4 bytes should be no problem.

    Your patience and help is appreciated !!

Children
No Data
Related