Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 228386

Forum Post: RE: MSP430FR5739 Data save on Power Reset

$
0
0

Hi Obie,

The way that you can set a specific address for this section to always be located is to modify the linker file again. Where it currently says:

FRAM : origin = 0xC200, length = 0x3D80

You could put instead:

    //FRAM                    : origin = 0xC200, length = 0x3D80     FRAM     : origin = 0xC200, length = 0x3B80 //FRAM without last 512 bytes     MY_FRAM    : origin = 0xFD80, length = 0x0200 //section for .myVars

Now you have a separate section called MY_FRAM that is the last 0x200 (512) bytes of the FRAM area, starting at 0xFD80.

Now you would go back down to the bottom of the linker file where you set up .myVars before. Instead of having it in the GROUP(READ_WRITE_MEMORY) like you did before, you need to remove it there and put it instead below the GROUP(ALL_FRAM), so it will go here:

       GROUP(EXECUTABLE_MEMORY)        {           .text       : {}                   /* CODE                              */        } ALIGN(0x0200), RUN_START(fram_rx_start)     } > FRAM      .myVars   : {}  > MY_FRAM //space allocated to store variables in FRAM      .jtagsignature : {} > JTAGSIGNATURE   /* JTAG SIGNATURE                    */     .bslsignature  : {} > BSLSIGNATURE    /* BSL SIGNATURE                     */     .jtagpassword                         /* JTAG PASSWORD                     */

And you place .myVars in the MY_FRAM section you made above. Now .myVars will always be in the last 512 bytes of your FRAM.

Personally, I do not like doing this as well as putting your data in the READ_WRITE_MEMORY section in ALL_FRAM like we did before and allowing the linker to decide the address where it should be. Here is the reason why - you can see in the linker file that there are 3 values fram_rw_start, fram_ro_start, and fram_rx_start, that the linker defines in order to help you create your MPU settings. Keeping data with the same read/write/execute permissions grouped together inside the FRAM allows you to set up the MPU with correct permissions on each segment - and you can only make 3 segments with the MPU. Therefore, you want to keep all of your read/write permission data together in one place, so that you can set only that portion of FRAM to have read/write permissions and lock down all the rest of it (like your code space).

If you keep your data within the groups defined in the linker file, then when you are done with code development and want to set up your MPU, you can find in your .map file the values for fram_rw_start, fram_ro_start, and fram_rx_start, and simply plug these addresses in for your MPU settings, making it easy - the linker has already done all the work of figuring out exactly what size each of the sections needs to be and rounded it to the correct alignment for the granularity of the MPU.

On the other hand, if you have created your own FRAM section at the end, this is outside of the automatic grouping that the linker was doing, so you may not have all of your read/write data in one place, making it where you aren't going to be able to set up the MPU to protect these sections correctly - you could have some read/write data at 0xC200 and other read/write data at your 0xFB80 address that you defined.

Further, if you use an array or structure to store your data, then you should not need to know the absolute address where it is defined because you can simply access it using a pointer to the array or structure.

Regards,

Katie


Viewing all articles
Browse latest Browse all 228386

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>