请教TI工程师:
原先使用MSP430FR5994单片机 里面的INFO区域相当于SRAM 同时又可以掉电保存 可以通过SRAM方式进行任何字节大小读取和写入操作。
问一下 MSP432P4111单片机 这个INFO区域 是不是只能当成FLASH进行操作 需要写入数据时 必须先进行块擦除 再写入 。
我现在需要使用一块存储区域 平时写入数据 掉电可以保存 是不是MSP432 这个INFO区域不能满足这种需求?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
请教TI工程师:
原先使用MSP430FR5994单片机 里面的INFO区域相当于SRAM 同时又可以掉电保存 可以通过SRAM方式进行任何字节大小读取和写入操作。
问一下 MSP432P4111单片机 这个INFO区域 是不是只能当成FLASH进行操作 需要写入数据时 必须先进行块擦除 再写入 。
我现在需要使用一块存储区域 平时写入数据 掉电可以保存 是不是MSP432 这个INFO区域不能满足这种需求?
您可以使用INFO区域(除去TLV),但不建议您使用MSP432 这个INFO区域来存储掉电保存数据。参考下图

INFO区域主要是用来存放一些预编程程序 BSL等,用户使用很容易出现问题
建议使用MAIN MEMORY。您可以参考下下面的程序,每次重置设备后,MAIN BANK 1, SECTOR 31 的var1 就会加1.
在CCS调试时,在project properties->debug->MSP432 Settings选择Erase and download necessary segments only
附上CMD文件
/****************************************************************************** * * Copyright (C) 2012 - 2016 Texas Instruments Incorporated - http://www.ti.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Default linker command file for Texas Instruments MSP432P401R * * File creation date: 2016-06-29 * *****************************************************************************/ --retain=flashMailbox MEMORY { MAIN (RX) : origin = 0x00000000, length = 0x0003F000 MYDATA (RX) : origin = 0x0003F000, length = 0x00001000 INFO (RX) : origin = 0x00200000, length = 0x00004000 #ifdef __TI_COMPILER_VERSION__ #if __TI_COMPILER_VERSION__ >= 15009000 ALIAS { SRAM_CODE (RWX): origin = 0x01000000 SRAM_DATA (RW) : origin = 0x20000000 } length = 0x00010000 #else /* Hint: If the user wants to use ram functions, please observe that SRAM_CODE */ /* and SRAM_DATA memory areas are overlapping. You need to take measures to separate */ /* data from code in RAM. This is only valid for Compiler version earlier than 15.09.0.STS.*/ SRAM_CODE (RWX): origin = 0x01000000, length = 0x00010000 SRAM_DATA (RW) : origin = 0x20000000, length = 0x00010000 #endif #endif } /* The following command line options are set as part of the CCS project. */ /* If you are building using the command line, or for some reason want to */ /* define them here, you can uncomment and modify these lines as needed. */ /* If you are using CCS for building, it is probably better to make any such */ /* modifications in your CCS project and leave this file alone. */ /* */ /* A heap size of 1024 bytes is recommended when you plan to use printf() */ /* for debug output to the console window. */ /* */ /* --heap_size=1024 */ /* --stack_size=512 */ /* --library=rtsv7M4_T_le_eabi.lib */ /* Section allocation in memory */ SECTIONS { .intvecs: > 0x00000000 .text : > MAIN .const : > MAIN .cinit : > MAIN .pinit : > MAIN .init_array : > MAIN .mydata : {} > MYDATA .binit : {} > MAIN /* The following sections show the usage of the INFO flash memory */ /* INFO flash memory is intended to be used for the following */ /* device specific purposes: */ /* Flash mailbox for device security operations */ .flashMailbox : > 0x00200000 /* TLV table for device identification and characterization */ .tlvTable : > 0x00201000 /* BSL area for device bootstrap loader */ .bslArea : > 0x00202000 .vtable : > 0x20000000 .data : > SRAM_DATA .bss : > SRAM_DATA .sysmem : > SRAM_DATA .stack : > SRAM_DATA (HIGH) #ifdef __TI_COMPILER_VERSION__ #if __TI_COMPILER_VERSION__ >= 15009000 .TI.ramfunc : {} load=MAIN, run=SRAM_CODE, table(BINIT) #endif #endif } /* Symbolic definition of the WDTCTL register for RTS */ WDTCTL_SYM = 0x4000480C;
以及C文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* -------------------------------------------
* MSP432 DriverLib - v3_50_00_02
* -------------------------------------------
*
* --COPYRIGHT--,BSD,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
/*******************************************************************************
* MSP432 Flash Controller - Programming Calibration Data
*
* Description: This example shows the use of the the Flash Controller APIs
* to erase and program simulated calibration data to a specific area in memory.
* Data in this example is programmed to user area of memory. The "fake"
* calibration data is stored in a RAM array and set using the memset function,
* however in a real application this buffer would be filled out using a serial
* interface such as I2C.
*
* MSP432P401
* ------------------
* /|\| |
* | | |
* --|RST |
* | |
* | |
* | |
* | |
* | |
*
* Author: Timothy Logan (Modified by John Morrison for this E2E post)
******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#define CALIBRATION_START 0x0003F000
/* Statics */
uint16_t simulatedCalibrationData[2048];
/* pragmas to define the variables in flash */
#pragma DATA_SECTION(var1, ".mydata");
#pragma DATA_ALIGN(var1, 2);
uint16_t var1, var1LOCAL = 0;
int main(void)
{
var1LOCAL = var1;
var1LOCAL++;
/* Since this program has a huge buffer that simulates the calibration data,
* halting the watch dog is done in the reset ISR to avoid a watchdog
* timeout during the zero
*/
/* Setting our MCLK to 48MHz for faster programming */
MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
FlashCtl_setWaitState(FLASH_BANK0, 2);
FlashCtl_setWaitState(FLASH_BANK1, 2);
MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
/* Initializing our buffer to a pattern of 0xA5 */
memset(simulatedCalibrationData, 0xA5, 4096);
simulatedCalibrationData[0] = var1LOCAL;
/* Unprotecting Info Bank 0, Sector 0 */
MAP_FlashCtl_unprotectSector(FLASH_MAIN_MEMORY_SPACE_BANK1,FLASH_SECTOR31);
/* Trying to erase the sector. Within this function, the API will
automatically try to erase the maximum number of tries. If it fails,
trap in an infinite loop */
if(!MAP_FlashCtl_eraseSector(CALIBRATION_START))
while(1);
/* Trying to program the memory. Within this function, the API will
automatically try to program the maximum number of tries. If it fails,
trap inside an infinite loop */
if(!MAP_FlashCtl_programMemory(simulatedCalibrationData,
(void*) CALIBRATION_START, 4096))
while(1);
/* Setting the sector back to protected */
MAP_FlashCtl_protectSector(FLASH_MAIN_MEMORY_SPACE_BANK1,FLASH_SECTOR31);
/* Going to LPM3 when not in use */
while (1)
{
MAP_PCM_gotoLPM3();
}
}