📄 memory.c
字号:
/*
*********************************************************************************************************
* msp430
* memory functions
*
* File : MEMORY.C
* Data : April 12, 2007
*********************************************************************************************************
*/
#include "hal.h"
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
/*
__no_init
char PmMode @LCDM1_
char FrameCS @LCDM2_
char PLateNow @LCDM3_ //
char LED_CTL0 @LCDM4_
char LED_CTL1 @LCDM5_
char RF0CTRL @LCDM6_
char RF0CNT @LCDM7_
char RF0ERR @LCDM8_
char Key_save @LCDM9_
@LCDM10_
WaiterId[5] @LCDM11_
@LCDM12_
@LCDM13_
@LCDM14_
@LCDM15_
PleatInfo @LCDM16_
@LCDM17_
@LCDM18_
@LCDM19_
@LCDM20_
@LCDAVCTL1_
@DAC12_0DAT_ //12bit
@TACCR1_ //16bit
@TACCR2_ //16bit
*/
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const char EepromShadow0[0x80] = {
0x0f,0x00, //write eeprom flag // write info flash flag
0x00,0x00, //SysCtrL;
0x00,0x00, //PlateFlag;
0x00,0x00, //BottleMinWeight
0x00,0x00, //HandleMinWeight;
0x00,0x00,
0x00,0x00,
0x00,0x00, //16
0x00,0x00,0x00,0x00, //MaxSpan
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, //16+32
0x00,0x00,0x00,0x00, //Cal0Min
0x00,0x00,0x00,0x00, //Cal0Max
0x00,0x00,0x00,0x00, //Cal1Min
0x00,0x00,0x00,0x00, //Cal1Max
0x00,0x00,0x00,0x00, //Cal2Min
0x00,0x00,0x00,0x00, //Cal2Max
0x00,0x00,0x00,0x00, //Cal3Min
0x00,0x00,0x00,0x00, //Cal3Max
0x00,0x00,0x00,0x00, //Cal4Min
0x00,0x00,0x00,0x00, //Cal4Max
};
//------------------------------------------------------------------------------
const char EepromShadow1[0x80] = {
0x0f, // CC setting update flag
0x06, // IOCFG2 Y //0x06
0x2E, // IOCFG1 Y
0x3a, // IOCFG0D Y
0x07, // FIFOTHR Y
0xD3, // SYNC1 Y
0x91, // SYNC0 Y
0xFF, // PKTLEN Y
0x04, // pktctrl1
0x05, // pktctrl0
0x00, // addr Y
0x00, // CHANNR Y
0x0C, // FSCTRL1 Frequency synthesizer control.0X17 0x0c
0x00, // FSCTRL0 Frequency synthesizer control.
0x23, // FREQ2 Frequency control word, high byte.
0x34, // FREQ1 Frequency control word, middle byte.
0x2E, // FREQ0 Frequency control word, low byte.
0xC8, // MDMCFG4 Modem configuration. x2D 0x0e
0x93, // MDMCFG3 Modem configuration.
0x03, // MDMCFG2 Modem configuration.
0x03, // MDMCFG1 Modem configuration.0x22
0xF8, // MDMCFG0 Modem configuration.
0x34, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
0x07, // MCSM2
0x00, // MCSM1
0x18, // MCSM0 Main Radio Control State Machine configuration.
0x15, // FOCCFG Frequency Offset Compensation Configuration.
0x6C, // BSCFG Bit synchronization Configuration.
0x83, // AGCCTRL2 AGC control.
0x40, // AGCCTRL1 AGC control.
0x91, // AGCCTRL0 AGC control.
0x87, // WOREVT1
0x6b, // WOREVT0
0xf8, // WORCTRL
0x56, // FREND1 Front end RX configuration.
0x10, // FREND0 Front end RX configuration.
0xA9, // FSCAL3 Frequency synthesizer calibration.
0x2A, // FSCAL2 Frequency synthesizer calibration.
0x00, // FSCAL1 Frequency synthesizer calibration.
0x0D, // FSCAL0 Frequency synthesizer calibration.(38)
0x41, // RCCTRL1
0x00, // RCCTRL0
0x59, // FSTEST
0x7F, // PTEST
0x3F, // AGCTEST
0x86, // TEST2
0x3D, // TEST1
0x09, // TEST0
0x03,0x0D,0x1C,0x34,0x67,0x60,0x85,0xc3, //PaTable[8]
//0x38
};
/*
*********************************************************************************************************
* CopyEep2Flash
*
* Description :Programs the calibration constants CalMinTmp and CalMaxTmp into Flash
* info memory segment A using in-system self programming techniques
* Arguments :
* Returned Values : none
* Note(s)/Warnings :
*********************************************************************************************************
*/
void CopyEep2Flash(char infox){
char *Flash_ptr; // Segment pointer
unsigned int i;
char EepAddr;
if('A'){ // write segment A
Flash_ptr = (char *) 0x1080; // Initialize Flash segment pointer
EepAddr = 0x00;
}else{ // 'B' write segment B
Flash_ptr = (char *) 0x1000; // Initialize Flash segment pointer
EepAddr = 0x80;
}
FCTL2 = FWKEY + FSSEL1 + FN1; // SMCLK/3 = ~333kHz
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptr = 0; // Dummy write to erase Flash segment
// *(unsigned int *)0x1080 = 0;
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
HandleMinWeight = 15;
BottleMinWeight = 300;
//for (i=0; i<128; i++){
//*Flash_ptr++ = I2C_Read_Byte(EepAddr++); // Copy value eeprom to segment
//}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
/*******************************************************************************
* ● For absolute placement, use the @ operator and the #pragma location directive
* Use the @ operator or the #pragma location directive to place individual global
* and static variables at absolute addresses. The variables must be declared either
* __no_init or const. This is useful for individual data objects that must be located
* at a fixed address, for example variables with external requirements, or for
* populating any hardware tables similar to interrupt vector tables. Note that it is not
* possible to use this notation for absolute placement of individual functions.
* ● For segment placement, use the @ operator and the #pragma location directive
* Use the @ operator or the #pragma location directive to place groups of functions
* or global and static variables in named segments, without having explicit control of
* each object. The variables must be declared either __no_init or const. The
* segments can, for example, be placed in specific areas of memory, or initialized or
* copied in controlled ways using the segment begin and end operators. This is also
* useful if you want an interface between separately linked units, for example an
* application project and a boot loader project. Use named segments when absolute
* control over the placement of individual variables is not needed, or not useful.
*******************************************************************************
* DATA PLACEMENT AT AN ABSOLUTE LOCATION
*
* Declaring located variables extern and volatile
* extern volatile const __no_init int x @ 0x100;
* __no_init char alpha @ 0x0200; // OK
* #pragma location = 0x0202
* volatile const int beta; // OK
* volatile const int gamma @ 0x0204 = 3; // OK
*
* volatile __no_init const char c @ 0x0204; //aligned
* void foo(void) { a = b + c + d;}
*******************************************************************************
* DATA AND FUNCTION PLACEMENT IN SEGMENTS
*
* Variables:
* __no_init int alpha @ "MYSEGMENT"; // OK
* #pragma location="MYSEGMENT"
* const int beta; // OK
* const int gamma @ "MYSEGMENT" = 3; // OK
*
* Functions:
* void f(void) @ "MYSEGMENT";
* void g(void) @ "MYSEGMENT"{ }
* #pragma location="MYSEGMENT"
* void h(void);
******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -