Jump to content
43oh

msp430f5529 save to flash memory


Recommended Posts

Hello guys i'm working on an application where i need to save 2 float numbers in flash memory (i need them when the msp lose power) ,i have the hardware part done but i can't figure out the coding i'm very new to programing.

I need to do something like this.

int sensorPin = 23;  
int sensorValue = 0; 
float volt;

// loop part
sensorValue = analogRead(sensorPin); 
unsigned long currentMillis = millis();
 timp=currentMillis/1000;

if(currentMillis - previousMillis > interval) {
    	previousMillis = currentMillis;   
     	volt=sensorValue;
     	volt=(volt*3.3)/4096;
     	volt=volt*8.51;
		putere1=volt*amp1;
		total_putere1=putere1+total_putere1;
}
 	media_puteri1=total_putere1/timp;
  	energie1=media_puteri1*timp/3600;

I need to save "energie1" to flash and whe my msp lose power the value stays on and then when i power it back my "energie1" value goes something like this energie1=(media_puteri1*timp/3600)+flash_value;

PS: i read the ENERGIA flash write/read exemple but i don't understand how to save float values;

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...