Lukman 1 Posted March 22, 2018 Share Posted March 22, 2018 Hello Guys Good Day for All, I just open the Mspflash example from energia example using MSP4305969LP board. But when I compile, it show error as below picture. Any one can help me? Thanks a lot. Best Regards, Lukman Quote Link to post Share on other sites
energia 485 Posted March 22, 2018 Share Posted March 22, 2018 MSPFlash is not compatible with FR devices as they have FRAM and not FLASH. Please see the Sketch below for writing to FRAM. In this case the Sketch places a variable called count in FRAM. Then count is increased by 1 each time through the loop. You will see that count will continue increasing after a reset or power cycle. You can attribute any variable with PLACE_IN_FRAM. Please see in the example placing a structure in FRAM. #define PLACE_IN_FRAM __attribute__((section(".text"))) #define ENABLE_FRAM_WRITE SYSCFG0 = FRWPPW | DFWP #define DISABLE_FRAM_WRITE FRWPPW | PFWP | DFWP uint8_t unsigned long count PLACE_IN_FRAM; struct data { uint16_t count; uint8_t foo[32]; uint32_t bar; }; struct data mydata PLACE_IN_FRAM; void setup() { Serial.begin(115200); } void loop() { Serial.print("Value: "); Serial.println(count); Serial.print("Count in struct: "); Serial.println(mydata.count); /* * Uncomment for devices such as the FR2433 that need their FRAM unlocked * Before FRAM can be writen to */ // ENABLE_FRAM_WRITE; // Program FRAM write enable count++; // Record the port event in FRAM mydata.count += 2; /* * Uncomment for devices such as the FR2433 FRAM lock */ // DISABLE_FRAM_WRITE; // Program FRAM write protected (not writable) delay(1000); } Quote Link to post Share on other sites
Lukman 1 Posted March 23, 2018 Author Share Posted March 23, 2018 Hello, Thank you for your explanation & sample code. This code is for writing FRAM right? Do you have sample code for read FRAM also? And If I want to write new data, is it will automatic replace the old data inside the FRAM? or I need to erase it first? Thank you. Best Regards, Lukman Quote Link to post Share on other sites
energia 485 Posted March 23, 2018 Share Posted March 23, 2018 One does not explicitly write to FRAM. You just change the value of what is stored in FRAM and it will survive a power cycle or reset. Did you run the Sketch and observe the values as I described? See the count++ and mydate +=2. This is equivalent to a FLASH write. Those incremental values will be there after a reset or reboot. Just run the Sketch and then reset power cycle the board and you will see the result in the Serial monitor. Lukman 1 Quote Link to post Share on other sites
veryalive 49 Posted March 23, 2018 Share Posted March 23, 2018 As I'm just learning about FRAM on Energia -- and referring to the example above: QUESTION --- does count need to be declared persistent ? (or other declared as other type?) cheers, Quote Link to post Share on other sites
energia 485 Posted March 23, 2018 Share Posted March 23, 2018 As you can see from the Sketch, count is attributed with PLACE_IN_FRAM. Same for mydata which is of type struct data. This makes it "persistent". PLACE_IN_FRAM is defined as __attribute__((section(".text"))) at the top of the Sketch. veryalive 1 Quote Link to post Share on other sites
Lukman 1 Posted March 26, 2018 Author Share Posted March 26, 2018 Hello, Thank you for your sample code. I just run the sketch, the count looks good, event I already reset. So regarding my question before, about how to read from FRAM, I can directly use the value from count variable. And it will auto replace the old value once we replace. Thank you for your help. Best Regards, Lukman Quote Link to post Share on other sites
energia 485 Posted April 1, 2018 Share Posted April 1, 2018 You do not explicitly "read" from FRAM. You just use the variable as you would normally do and yes, the "old" value is updated with the new value and stored in FRAM. Quote Link to post Share on other sites
Lukman 1 Posted April 12, 2018 Author Share Posted April 12, 2018 Hi Energia, I know this is energia forum, but yesterday I just try implemented the FRAM code you give to me using CCS 8. It showing error invalid combination of type specifier. Please see the attached file. I am wondering whether do you have any comment? Thanks a lot. Best Regards, Lukman Quote Link to post Share on other sites
Fmilburn 445 Posted April 12, 2018 Share Posted April 12, 2018 It is being declared both uint8_t and unsigned long - it should be one or the other. Maybe the GCC compiler accepts this and the TI does nor. Quote Link to post Share on other sites
Lukman 1 Posted April 13, 2018 Author Share Posted April 13, 2018 Hi @Fmilburn , Yes I know about that, is there any way I can write it in another way? I appreciate your help. Thanks a lot. Best Regards, Lukman Quote Link to post Share on other sites
Lukman 1 Posted April 13, 2018 Author Share Posted April 13, 2018 (edited) Hi @Fmilburn & @energia , I know its out of topic, but I have a project to counter up & counter down. This counter up or counter down using interrupt and depend on ADC value. If the ADC value higher than certain value, it will counter up, once it lower than certain value it will counter down. I have write the code using energia but still doesn't work. I am wondering whether you are guys can help me to solve the problem. I appreciate your help. Best Regards, Lukman. Edited April 13, 2018 by Lukman already solve the problem Quote Link to post Share on other sites
Fmilburn 445 Posted April 13, 2018 Share Posted April 13, 2018 This may seem rough but you are not going to learn to code by asking questions like these and need to start figuring out some of this on your own. You do not seem to have an understanding of the C/C++ languages. I suggest getting a book or taking an online course. Start with simpler problems if necessary but learn to solve problems yourself. RE: code that does not compile - decide whether you want to have an uint8_t variable or an unsigned long variable and then declare it as such. E.G. for unsigned long: unsigned long counter PLACE_IN_FRAM; Regarding your counter code above. This appears to be something copied from somewhere and has code not necessary for what you are trying to do such as the unused variables fadeValue and NUM_READS. You do not say why it doesn't work or what you have done to try and fix it. This is not the kind of thing people will want to spend time on trying to help you figure out. Break it into pieces you understand, test them until they work as you want, and then put it back together piece by piece testing as you go. Quote Link to post Share on other sites
Lukman 1 Posted April 13, 2018 Author Share Posted April 13, 2018 Hi @fmilburn, Thanks a lot, I really appreciate your suggestion. I will try to do your advise. Best Regards, Lukman Quote Link to post Share on other sites
Lukman 1 Posted April 16, 2018 Author Share Posted April 16, 2018 Hi All, Sorry for disturb, I solve already my problem. Thanks all. Best Regards, Lukman Fmilburn 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.