/******************************************************************************* * Copyright (C) 2010-2011 Maxim Integrated Products, All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Maxim Integrated Products * shall not be used except as stated in the Maxim Integrated Products * Branding Policy. * * The mere transfer of this software does not imply any licenses * of trade secrets, proprietary technology, copyrights, patents, * trademarks, maskwork rights, or any other form of intellectual * property whatsoever. Maxim Integrated Products retains all ownership rights. * * Module Name: Flash and SRAM Data Object * Description: Demonstrates Memory map and initialization with IAR * Filename: memory.h * Author: SKJ * Compiler: IAR Compiler version 2.20I * ******************************************************************************* */ /******************************************************************************* * USER NOTE: ******************************************************************************* * Need to check "Place constants in CODE" in Project->Options/General Options * /Target ******************************************************************************/ //Memory map Structures //Flash Data Object0 typedef struct { unsigned char SYSTEM_CONFIG; //Address 0x00 unsigned char TEMP_CONFIG; //Address 0x01 unsigned char SLAVE_ADDR_A0; //Address 0x02 unsigned char NULL_A0_3; //Address 0x03 /* Important Note: NULL_A0_3 is dummy variable and necessary. This will allocate the next integer variable at even memory address. */ signed int INTERNAL_TEMP_THRES; //Address 0x04-5 signed int EXTERNAL_TEMP_THRES; //Address 0x06-7 signed int DS75_TEMP_THRES; //Address 0x08-9 }FlashMemory0; //Flash Data Object1 typedef struct { unsigned char SYSTEM_CONFIG; //Address 0x00 unsigned char TEMP_CONFIG; //Address 0x01 unsigned char SLAVE_ADDR_A2; //Address 0x02 unsigned char NULL_A1_3; //Address 0x03 signed int INTERNAL_TEMP_THRES; //Address 0x04-5 signed int EXTERNAL_TEMP_THRES; //Address 0x06-7 signed int DS75_TEMP_THRES; //Address 0x08-9 signed int VOLT_CONFIG; //Address 0x0A-B }FlashMemory1; //SRAM Data Object //Monitoring Parameters (SRAM) structure typedef struct { //Read Only signed int INTERNAL_TEMP; //Address = OFFSET + 0x00-1 signed int EXTERNAL_TEMP; //Address = OFFSET + 0x02-3 signed int DS75_TEMP; //Address = OFFSET + 0x04-5 signed int VOLTAGE0; //Address = OFFSET + 0x06-7 signed int VOLTAGE1; //Address = OFFSET + 0x08-9 }SRAMMemoryMap; //Start location of CONFIGURATION in flash #define CONFIG_FLASH 0xEE00 //Start location of SRAM where CONFIGURATION are loaded from flash #define CONFIG_SRAM 0x100 //CONFIGURATION Start Address #define FLASH_START_ADDRESS 0x00 //CONFIGURATION SIZE #define FLASH_DATA_SIZE0 sizeof(FlashMemory0) #define FLASH_DATA_SIZE1 sizeof(FlashMemory1) //CONFIGURATION END ADDRESS (I2C Memory Map) #define FLASH0_END_ADDRESS FLASH_START_ADDRESS + FLASH_DATA_SIZE0 #define FLASH1_END_ADDRESS FLASH0_END_ADDRESS + FLASH_DATA_SIZE1 //Start location of MONITORING Parameter in SRAM #define SRAM_START_ADDRESS_OFFSET 0x40 //MONITORING Parameter SIZE #define SRAM_DATA_SIZE sizeof(SRAMMemoryMap) //END ADDRESS of MONITORING Parameter #define SRAM_END_ADDRESS SRAM_START_ADDRESS + SRAM_DATA_SIZE /* Flash Data memory map design shown below Size of Structure FlashMemory0 = 10 Bytes (0x0A) Size of Structure FlashMemory1 = 12 Bytes (0x0C) Flash Memory Map Flash0 Start Address = 0xEE00 Flash0 End Address = 0xEE00 + 0x0A - 1 //End Address = 0xEE09 Flash1 Start Address = 0xEE00 + 0x0A (or Flash0 End Address + 1 = 0xEE0A) Flash1 End Address = 0xEE00 + 0x0A + 0x0C - 1 //End Address = 0xEE15 INITIALIZED FLASH_DATA Start Address = Flash1 End Address + 1 //0xEE16 UNINITIALIZED FLASH_DATA Start Address = INITIALIZED FLASH_DATA End Address + 1 //0xEE18 ************************************************************************ * FLASH MEMORY MAP * ************************************************************************ |----------------------------------------------------------------------|0xEE00 | | | DATA OBJECT FLASH_CONFIG0 (10 Bytes) | | | |----------------------------------------------------------------------|0xEE09 |----------------------------------------------------------------------|0xEE0A | | | DATA OBJECT FLASH_CONFIG1 (12 Bytes) | | | |----------------------------------------------------------------------|0xEE15 |----------------------------------------------------------------------|0xEE16 | | | INITIALIZED FLASH_DATA (2 Bytes) | | | |----------------------------------------------------------------------|0xEE17 |----------------------------------------------------------------------|0x0118 | | | UNINITIALIZED FLASH_DATA (2 Bytes) | | | |----------------------------------------------------------------------|0x0119 */ #pragma location = CONFIG_FLASH //Address where constant will reside in flash const FlashMemory0 FLASH_CONFIG0 = { 0x00, // SYSTEM_CONFIG 0xFE, // TEMP_CONFIG 0xA0, // SLAVE_ADDR_A0 0x00, // NULL_A0_3 0x3200, // INTERNAL_TEMP_THRES 0x4200, // EXTERNAL_TEMP_THRES 0x5200 // DS75_TEMP_THRES }; #pragma required = FLASH_CONFIG0 #pragma location = CONFIG_FLASH + FLASH_DATA_SIZE0 //Address where constant will reside in flash const FlashMemory1 FLASH_CONFIG1 = { 0x00, // SYSTEM_CONFIG 0xFE, // TEMP_CONFIG 0xA2, // SLAVE_ADDR_A0 0xFF, // NULL_A2_3 0x6200, // INTERNAL_TEMP_THRES 0x7200, // EXTERNAL_TEMP_THRES 0x8200, // DS75_TEMP_THRES 0x0003 // VOLT_CONFIG }; #pragma required = FLASH_CONFIG1 #pragma location = CONFIG_FLASH + FLASH_DATA_SIZE0 + FLASH_DATA_SIZE1 const int INIT_FLASH_DATA = 0xAA55; //Initialized Flash Data #pragma required = INIT_FLASH_DATA #pragma location = CONFIG_FLASH + FLASH_DATA_SIZE0 + FLASH_DATA_SIZE1 + 2 __no_init const int NO_INIT_FLASH_DATA; //Uninitialized Flash Data #pragma required = NO_INIT_FLASH_DATA /* ************************************************************************ * SRAM MEMORY MAP * ************************************************************************ |----------------------------------------------------------------------|0x0100 | | | DATA OBJECT FLASH_CONFIG0 (10 Bytes) | | | |----------------------------------------------------------------------|0x0109 |----------------------------------------------------------------------|0x010A | | | DATA OBJECT FLASH_CONFIG1 (12 Bytes) | | | |----------------------------------------------------------------------|0x0115 |----------------------------------------------------------------------|0x0116 | | | INITIALIZED FLASH_DATA (2 Bytes) | | | |----------------------------------------------------------------------|0x0117 |----------------------------------------------------------------------|0x0118 | | | UNINITIALIZED FLASH_DATA (2 Bytes) | | | |----------------------------------------------------------------------|0x0119 |----------------------------------------------------------------------|0x011A | | | DATA OBJECT DATA_MONITOR | | | |----------------------------------------------------------------------|0x0123 */ /******************************************************************************* * USER NOTE: ******************************************************************************* * Flash Data are mapped in SRAM memory and RecallConfigFromFlash() will update * SRAM structures from flash structures on every power up. * User can call StoreConfigInFlash() function to write SRAM structures to Flash * structures. ********************************************************************************/ //Below Structures start at CONFIG_SRAM Location in SRAM and they are not //initialized #pragma location = CONFIG_SRAM __no_init FlashMemory0 CONFIGURATION0; #pragma required = CONFIGURATION0 #pragma location = CONFIG_SRAM + FLASH_DATA_SIZE0 __no_init FlashMemory1 CONFIGURATION1; #pragma required = CONFIGURATION1 #pragma location = CONFIG_SRAM + FLASH_DATA_SIZE0 + FLASH_DATA_SIZE1 __no_init int Flash_Data; //INITIALIZED flash data SRAM mapped variable #pragma required = Flash_Data #pragma location = CONFIG_SRAM + FLASH_DATA_SIZE0 + FLASH_DATA_SIZE1 + 2 __no_init int NO_INIT_Flash_Data; //UNINITIALIZED flash data SRAM mapped variable #pragma required = NO_INIT_Flash_Data /************************************************************************** * USER NOTE: ************************************************************************** * Below structure is defined in SRAM only. Here this is defined for * application to update the data which can be read by external interface. * Application program can prevent any external write operation (optional) * between address 0x11A to 0x123 (10 Bytes which is size of Data Monitor) * from external interface. **************************************************************************/ //DATA_MONITOR Structure will start SRAM address at CONFIG_SRAM + FLASH_DATA_SIZE0 + FLASH_DATA_SIZE1 + 4 #pragma location = CONFIG_SRAM + FLASH_DATA_SIZE0 + FLASH_DATA_SIZE1 + 4 __no_init SRAMMemoryMap DATA_MONITOR; #pragma required = DATA_MONITOR //End Memory.h