تG
ܽdp C yӦsxsbְ{O (Flash) ѼơC

`NGb params.h AwqnѼƪc (struct) ApUҥܡC

typedef struct
{
    unsigned char ucSequenceNum;
    unsigned char ucCRC;
    unsigned char ucVersion;
    
    //PRESERVE ABOVE THREE PARAMETERS FOR FLASH READ/WRITE

    int counts;

    //
    // Padding to ensure the whole structure is 64 bytes long.
    //
    unsigned char ucReserved[57];
}
tParameters;

`NAc (struct) eTӦAucSequenceNum, ucCRC, ucVersionAO諸C
c (struct) bO餤ץO 64 줸AҥH̥ŧi@ ucReserved }CAӵc (struct)`@ 64 줸CWҤAcounts OϥΪ̦ۦwqA]iHwqPOAWL@ӼƶqܼƧ@c (struct) AOUץ[`ᥲO 64 줸C


================================================================================

Goal:
Demonstrate how to use C language to load/store parameters in flash.

Note that be sure to define parameters as members of struct in params.h as follows:

typedef struct
{
    unsigned char ucSequenceNum;
    unsigned char ucCRC;
    unsigned char ucVersion;
    
    //PRESERVE ABOVE THREE PARAMETERS FOR FLASH READ/WRITE

    int counts;

    //
    // Padding to ensure the whole structure is 64 bytes long.
    //
    unsigned char ucReserved[57];
}
tParameters;

Note that the former three members, ucSequenceNum, ucCRC, ucVersion, are not allowed to changed.
The total length in memory of the struct is 64 bytes. To keep the length of the struct as 64 bytes, add an array of ucReserved of specified length. In above example, counts is user-defined and user can define even more varibales and in more data types as long as the whole length of struct is 64 bytes.

