Hello, I'm trying to store an int in Flash
How do I write an INT to flash on MSP430?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello, I'm trying to store an int in Flash
How do I write an INT to flash on MSP430?
Hi,
What is the width of your flash? Are you asking this considering that MSP430 is 16-bit and int is 32-bit? Or in the manner considering that flash requires commands to enable write operation by writing appropriate command to its base address, followed by write operation.
What problem are you exactly facing?
Regards,
Sid
There is peace of my code how does I store structure in MSP430 Flash memory
void SAVEC()
{
int i;
unsigned char *ptr_flash, *ptr_ram;
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
ptr_flash = (unsigned char*)&ValOnFlash;
*ptr_flash = 0; // Dummy write to erase Flash seg B
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
ptr_ram = (unsigned char*)&ValOnRam;
for(i = 0; i < sizeof(calibration); i++ ){
*ptr_flash++ = *ptr_ram++;
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
ValOnFlash and ValOnRam have own sections in .cmd file.
Declared using #pragma
I used Msp430fG4168, it's 16bit microcontroller.
i don't understand : different between Rom and Flash in Msp430? Flash same EEPROM ( etc EEPROM in AVR microcontroller)?
I will try it. Thanks alot.
Hi,
for an explaination of Flash have a look at this: http://en.wikipedia.org/wiki/Flash_memory
for an explaination of EEPROM look at this: http://en.wikipedia.org/wiki/EEPROM
and finally, ROM is here: http://en.wikipedia.org/wiki/Read-only_memory
Flash and EEPROM were using different technologies. Flash is wearing out faster than EEPROM (and erase/write is damaging the process structures).
There is no EEPROM memory in MSP430 (AVR has both FLASH (for your application) and EEPROM (i.e. for data).
You can use the MSP430 INFO memory for storing i.e. calibration data but you can not update it that often as with an EEPROM.
Also you may want to have a look at this post: http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/18663/71969.aspx#71969.
The functions presented there work fine (and it also contains some other information which might be useful for you). The example presented uses MSP430F2274 but it explains how to write to flash memory.
Rgds
aBUGSworstnightmare
**Attention** This is a public forum