Electronic – Where to store non-volitile variables on ARM microcontroller

armembeddedmemorynon-volatile-memory

Noob question here. I have only a little experience with microcontrollers and all that experience was limited to the 8051. I am working on a project and would like to use the ARM cortex M4 microcontroller. Programming the microcontroller and setting up the registers and IO is easy enough. The project calls for a person to be able to input certain variables like time, weight, etc. Those values need to be stored in some non-volatile memory so that if the embedded system loses power the values will be retained.

Do any of the Cortex M4 microcontrollers have on-chip flash memory (or another form of non-volitile memory) that can be used for data? If yes, then how does the program specify this on-chip memory as the location to store the data?

If there is no on-chip memory as described above I assume a flash memory IC can be connected to the GPIO pins of the microcontroller to store the data externally. Are there any resources that would walk me through this process?

I do not need to store much data so using on-chip resources would be preferable compared with purchasing another IC just to store a few bytes of information.

Best Answer

You will have to read the datasheet for the particular chip you have in mind. There are some M4 chips with high-endurance (100,000 or higher) byte-erasable EEPROM (eg. R7FS7G27H3A01CFC) , others may have writeable flash but must be erased a sector at a time and endurance may be much less.

'ARM Cortex M4' only describes the base characteristics of the core. There are optional features, and the memory and peripheral complement will depend on the individual manufacturer's implementation.

You can easily and cheaply (starting at about 10 cents in quantity) use an I2C or SPI serial EEPROM if you want to store a few bytes of user data, so there is no need to make the inclusion of EEPROM a requirement for the MCU. For example, look at the 128 byte 24C01.

Some may also support a battery back-up, which is usually a bad choice for simple nonvolatile memory storage, but if you need a real-time clock and can stand the data disappearing sometimes when the battery runs down, it might be a viable option.