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.

LP-MSPM0G3507: Flash Memory Read error

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

  • How do you read the memory? Are you using the IDE to read FLASH directly?

  • uint8_t readFlashMemory8(uint32_t address) {
        uint8_t *ptr = (uint8_t *)address; // Adresi uint8_t türünde bir pointer'a dönüştür
        return *ptr; // Bu adresteki veriyi oku ve geri döndür
    }
    
    uint16_t readFlashMemory16(uint32_t address) {
        uint8_t lowByte = *((uint8_t *)address);
        uint8_t highByte = *((uint8_t *)(address + 1));
        return (highByte << 8) | lowByte;
    }

    I am writing this for informational purposes only. With these functions, I can go to the addresses of 8 and 16 bit values ​​and read them.

**Attention** This is a public forum