Jump to content

jackak

Members
  • Content Count

    2
  • Joined

  • Last visited

About jackak

  • Rank
    Noob Class
  • Birthday December 20

Profile Information

  • Location
    Ireland
  • Github
    https://github.com/jackakyle
  1. Hi Jozef, Thanks for that info, however I tried your recommendation and found that the variable, once set at 5, could not then be changed by other lines in the code (i.e. FRAM_count++) and instead would remain at five. This is similar to the behaviour I observed from the energia-defined PLACE_IN_FRAM, despite the fact that the data memory region the .persistent section is in is rwx. Is this the intended behaviour and am I simply misunderstanding the persistent attribute, or are there other factors at play here? I wondered if it could be an MPU issue, but my understanding is that the MPU is disabled by default? Thanks again for your suggestion!
  2. Hi folks! I am working on a project using an MSP430FR5994 through Energia 1.8.11E23 on Linux. As part of that project I would like to persist some variables, i.e. they are set once when the code is flashed and then if updated will retain the updated value upon power cycle, reset, etc. A simple counter example code I am using to test this is shown below. The desired behaviour is that the counter starts at 5 and then continues, and does not reset back to five even if the MSP is power cycled or reset. I have tried the existing undocumented PLACE_IN_FRAM (a macro for __attribute__((section(".text;")))), with both the original and the elf-GCC compilers. This sets the variable, but does not seem to allow it to be altered. I note that the section that this places the variable in, .text, is defined as read only in the linker scripts for both compilers. The original places the .text section it in the rom (rx) region while the elf compiler places it in the text (rx) region. This confuses me, as existing forum threads (e.g. https://forum.43oh.com/topic/13099-mspflash-do-not-work-on-msp4305969/?do=findComment&comment=80848) seemed to imply that this would create a persitent, read/writeable variable. The comment accompanying the macro in pins_energia.h also implies the same. I then tried using __attribute__((persistent)) with the new elf-GCC compiler during my variable declaraion. Upon compile, this gave the following warning "variable 'FRAM_count' was declared persistent and should be explicitly initialized [-Wattributes]". I was unable to resolve this, despite (by my understanding) explictly declaring the variable in a variety of ways. Unlike the previous approach, this did allow the variable to be written, with the count incrementing. However, upon power cycling the count reset to five and did not persist the variable. The code I used to test the above (and other) approaches is shown below: //uint8_t FRAM_count PLACE_IN_FRAM = 5; // Doesn't increment, seems to be read only after init unsigned long int FRAM_count __attribute__((persistent)) = { 5 }; // Doesn't persist, // Gives compiler warning: variable 'FRAM_count' was declared persistent and should be explicitly initialized [-Wattributes] //uint8_t FRAM_count __attribute__((section(".persistent"))) = { 5 }; // Doesn't increment void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.print("Initial value of FRAM_count is: "); Serial.println(FRAM_count, DEC); Serial.println("Setup Completed"); } void loop() { // put your main code here, to run repeatedly: Serial.println(FRAM_count, DEC); FRAM_count++; delay(1000); } Any suggestions or support that those of you more familiar with the Energia/MSP framework could give would be greatly appreciated! I have spent a few days on this now and have checked these and other forums but have thus far had no success.
×
×
  • Create New...