Storing application calibration info to CFG Area

This article applies to:
DolphinAPI

QUESTION

I have some application specific calibration information and I don’t want to loose them when re-flashing my application. Where to store it?

ANSWER

You can store it in the user part of the CFG area (between the address 0x80 – 0xFF counted relative from the PAGE start). The API does not provide write access to the CFG area therefore make sure to use the object attached to this note: FLASH_WRITE

To use the object you need to specify in your source code the following function:

//---------------------------------------------------------------------------------------------
//! \\brief  Writes a buffer to the flash when the program is executed from XRAM
//! 
//! Description: This function writes a buffer with given size to an address.
//!              
//!
//! \\param u8Buffer      Pointer to a data buffer in XRAM or IDATA or DATA
//! \\param u16Addr       Address to write the data to
//! \\param u8Size        Size of the data buffer
//! \\return u8Err        1-operation failed. 0-success
//---------------------------------------------------------------------------------------------
uint8 FLASH_CONTROL_write_buffer_XRAM(const uint8 *u8Buffer, uint16 u16Addr, uint8 u8Size);

EXAMPLE CODE:
This example sotres the u16CfgValue in configuration area to the 0x80 address.

cfg_write

  uint16 u16CfgValue;
 
 
  uint8 u8Result; 
 
  u8Result = FLASH_CONTROL_write_buffer_XRAM(&u16CfgValue, CFG_ADDR+0x80, sizeof(u16CfgValue)-1);

DOWNLOAD:
flash_control_write_buffer_xram.obj

FAQ Single Template