主题中讨论的其他器件:Energia
我一直在尝试在 FRAM 中正确设置在循环通电和闪存上传之间持续存在的变量。
我可以告诉大家的问题是 Energia 中的.noinit 位于 RAM 中、而不是 FRAM 中。
尝试了许多不同的组合后、如果我将这些变量放入.text、我可以使它们在功率周期之间保持不变。 例如: unsigned long __attribute__((section(".text"))) persist;
我已经尝试了几乎所有可以在网上找到的设置组合、尝试使.noinit 正常工作。
以下是几个、全部在一个 sketch 中:
#include <Energia.h> #include <Arduino.h> #include <msp430.h> // most launchpads have a red LED #define LED RED_LED //e2e.ti.com/.../msp430fr6989-need-read-and-write-example-code-for-fram-on-the-msp-device-for-energia //github.com/.../70 int i PLACE_IN_FRAM; //forum.43oh.com/.../ //forum.43oh.com/.../ uint8_t lo __attribute__((section(".infomem"))); //www.element14.com/.../msp430fr2633-fram //#pragma PERSISTENT(var) #pragma NOINIT(var) unsigned long var=0; //forum.43oh.com/.../ //stealing the noinit from www.element14.com/.../msp430fr2633-fram unsigned long __attribute__((section(".noinit"))) persist; #pragma NOINIT(thingsToStore) #pragma DATA_SECTION(thingsToStore, ".text") uint16_t __attribute__((section(".text"))) thingsToStore[10] ; // the setup routine runs once when you press reset: void setup() { //this breaks the code //WDTCTL = WDTPW | WDTHOLD; // Stop WDT // initialize the digital pin as an output. Serial1.begin(9600); pinMode(LED, OUTPUT); delay(100); Serial1.println("hello world!"); disableWatchDog(); i = 0; enableWatchDog(); //i = 0; } // the loop routine runs over and over again forever: void loop() { disableWatchDog(); //github.com/.../70 Serial1.print("hello world! "); Serial1.println(i++); enableWatchDog(); disableWatchDog(); //forum.43oh.com/.../ SYSCFG0 &= ~PFWP; // Program FRAM write enable lo = lo + 1; // Record in FRAM SYSCFG0 |= PFWP; // Program FRAM write protected (not writable) Serial1.print("lo and behold: "); Serial1.println(lo); enableWatchDog(); //www.element14.com/.../msp430fr2633-fram //this at least increments, but gets erased on startup SYSCFG0 = FRWPPW | DFWP; // Program FRAM write enable var++; // Increment the variable (aka, treat it like any other variable) SYSCFG0 = FRWPPW | PFWP | DFWP; // Program FRAM write protected (not writable) Serial1.print("no show: "); Serial1.println(var); //forum.43oh.com/.../ //it seems that messing with the wdt isn't needed :) //disableWatchDog(); SYSCFG0 = FRWPPW | DFWP; persist++; Serial1.print("does percistance pay: "); Serial1.println(persist); //enableWatchDog(); thingsToStore[0]++; Serial1.print("in the first box: "); Serial1.println(thingsToStore[0]); Serial1.print("and in the second... "); Serial1.println(thingsToStore[5],HEX); SYSCFG0 = FRWPPW | PFWP | DFWP; //this is no logic to what the initial values are if they weren't stored correctly digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
在有关将变量存储在 FRAM 中的应用手册中、他们讨论了需要修改链接器文件以将.init 移动到 FRAM 中。
对于.cmd 文件与示例中的文件相匹配的常规 CCS 工程、这似乎足够简单。
但我不知道如何修改似乎是 Energia 存储器映射的 MSP430.x/memory.x 文件。
TL:DR:如果我需要修改链接器以使 noinit 正常工作、那么我该如何做(对于 Energia)? 如果不是、最好的方法是什么?
谢谢、
Matt