This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I declare a structure or array in Flash memory?

H,
How would I declare a struct containing an array, or just an array or a struct for that matter, in Flash memory. I have read the variable placing example. But that only seems to work for simple variables.

The following code just declares it in RAM.

typedef struct
{
   int SampleList[200];
   unsigned long SLi_Next;
   unsigned long SLi_Max;
} STC_DataStorage;

//As a global
const STC_DataStorage Data;

Thanks.
Richard.

Parents
  • I have gone through the memory example. I am a little confused.

    According to the docs when a variable has the const keyword it will be placed in Flash.

    From the example snippet below, how do I define the start of the BSS section?

    /* Mapped to Intialized Data Section (.data) in Internal RAM */
    unsigned char FillVal = 0xff;
    
    
    /* Mapped to Uninitialized Data Section (.bss) in External RAM */
    
    unsigned char Buffer[32768];
    
    struct {
      unsigned short us[16];
      unsigned long  ul[8];
    } Table;
    

    Must I use malloc to allocate memory in FLash. I am a little confused by the keywords and what the compiler does with memory.

    Regards,
    Richard.

Reply
  • I have gone through the memory example. I am a little confused.

    According to the docs when a variable has the const keyword it will be placed in Flash.

    From the example snippet below, how do I define the start of the BSS section?

    /* Mapped to Intialized Data Section (.data) in Internal RAM */
    unsigned char FillVal = 0xff;
    
    
    /* Mapped to Uninitialized Data Section (.bss) in External RAM */
    
    unsigned char Buffer[32768];
    
    struct {
      unsigned short us[16];
      unsigned long  ul[8];
    } Table;
    

    Must I use malloc to allocate memory in FLash. I am a little confused by the keywords and what the compiler does with memory.

    Regards,
    Richard.

Children
No data