Jump to content
43oh

MSPflash do not work on MSP4305969


Recommended Posts

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);
}

 

Link to post
Share on other sites

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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

Link to post
Share on other sites
  • 2 weeks later...

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

1.jpg

Link to post
Share on other sites

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 by Lukman
already solve the problem
Link to post
Share on other sites

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...