Part Number: LP-MSPM0G3507
Tool/software:
Hello, I do not have any problems while writing to the false memory of my program. But when I reset the data I saved, I cannot read it. What am I doing wrong? Can you help me?
#include "ti_msp_dl_config.h"
/* Address in main memory to write to */
#define MAIN_BASE_ADDRESS (0x00001000)
/* Counter variable to store the value in flash */
uint8_t counter = 0;
uint8_t counter_value;
uint8_t read_value=0x00;
uint8_t readed_value;
uint8_t error;
volatile DL_FLASHCTL_COMMAND_STATUS gCmdStatus;
/* Error codes */
#define NO_ERROR 0
#define ERROR_ERASE 1
#define ERROR_8BIT_W 2
volatile uint8_t gErrorType = NO_ERROR;
void writeValueToFlash(uint32_t address, uint8_t *value){
DL_FlashCTL_unprotectSector(
FLASHCTL, address, DL_FLASHCTL_REGION_SELECT_MAIN);
DL_FlashCTL_eraseMemory(
FLASHCTL, address, DL_FLASHCTL_COMMAND_SIZE_SECTOR);
DL_FlashCTL_waitForCmdDone(FLASHCTL);
DL_FlashCTL_unprotectSector(
FLASHCTL, address, DL_FLASHCTL_REGION_SELECT_MAIN);
DL_FlashCTL_programMemory8WithECCGenerated(
FLASHCTL, address, value);
counter_value=*value;
}
int main(void)
{
SYSCFG_DL_init();
DL_FlashCTL_unprotectSector(
FLASHCTL, MAIN_BASE_ADDRESS, DL_FLASHCTL_REGION_SELECT_MAIN);
DL_FlashCTL_readVerifyFromRAM8WithECCGenerated(FLASHCTL, MAIN_BASE_ADDRESS, &read_value);
DL_FlashCTL_waitForCmdDone(FLASHCTL);
while (1) {
/* Increment the counter */
writeValueToFlash(MAIN_BASE_ADDRESS, &counter);
counter++;
delay_cycles(16000000);
}
}