Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

MSP432P401M: MSP432P401M NVS_write Error

$
0
0

Part Number: MSP432P401M

Hi,

I working on a custom board with a MSP432P401M microcontroller on it. I'm trying to store a value on the Flash using the NVS drivers but the write operation returns an error NVS_STATUS_ERROR (-1).

I'm using the following flash region

#define SECTORSIZE        0x1000
#defineNVS_REGIONS_BASE 0x1B000

#define REGIONSIZE       (SECTORSIZE * 1)

The initial Task initializes the NVS_init() and calls a function vNVSThreshold_loadInitial() to operate with the Flash

void *systemInitThread(void *arg0)
{
    Error_Block eb;
    Display_Params displayParams;
    /* Call driver init functions */
    ADCBuf_init();
    GPIO_init();
    PWM_init();
    // I2C_init();
    // SDSPI_init();
//    SPI_init();
    UART_init();
    // Watchdog_init();
    NVS_init();
    /* Configure & open Display driver */
    Display_Params_init(&displayParams);
    displayParams.lineClearMode = DISPLAY_CLEAR_BOTH;
    displayHandle = Display_open(Display_Type_UART, &displayParams);
    if (displayHandle == NULL) {
        Display_printf(displayHandle, 0, 0, "Error creating displayHandle\n");
        while (1);
    }
    Display_printf(displayHandle, 0, 0, "\033[2J\033[H");
    vNVSThreshold_loadInitial();
    vPWMLED_init();
    vADCBuff_init();
    vDiscreteIO_init();
    vHeartBeat_init();
//    sleep(1);
    usleep(10000);
//    vNVSThreshold_set(9000);
    Display_close(displayHandle);
    TTY_init();
    return 0;

}

the vNVSThreshold_loadInitial() looks like this:

#define THRESHOLD_DEFAULT_VALUE           10000
typedefstruct {
    uint32_ttest;
    uint32_tthreshold;
}NVSThreshold_data;
uint32_t g_ui32NVSThresholdValue;
voidvNVSThreshold_loadInitial()
{
    NVS_Handle nvsHandle;
    NVS_Attrs regionAttrs;
    NVS_Params nvsParams;
    int_fast16_t status;
    NVSThreshold_data data;
 
    NVS_Params_init(&nvsParams);
    nvsHandle = NVS_open(Board_NVSINTERNAL, &nvsParams);
    if (nvsHandle != NULL) {
        NVS_getAttrs(nvsHandle, &regionAttrs);
        // Erase the first sector of nvsRegion
//        status = NVS_erase(nvsRegion, 0, regionAttrs.sectorSize);
//        if (status != NVS_STATUS_SUCCESS) {
//            // Error handling code
//        }
        status = NVS_read(nvsHandle, 0, &data, sizeof(NVSThreshold_data));
        if (status == NVS_STATUS_SUCCESS) {
            if(data.test == 0xFFFFFFFF) {
                data.test = 0xA5A5A5A5;
                data.threshold = THRESHOLD_DEFAULT_VALUE;
                // Write "Hello" to the base address of nvsRegion, verify after write
                status = NVS_write(nvsHandle, 0, &data, sizeof(NVSThreshold_data), NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
//                status = NVS_write(nvsRegion, 0, "Hello", strlen("Hello") + 1, NVS_WRITE_POST_VERIFY);
                if (status != NVS_STATUS_SUCCESS) {
                    Display_printf(displayHandle, 0, 0, "Error Writing to NVS\n");
                }
            }
            g_ui32NVSThresholdValue = data.threshold;
            Display_printf(displayHandle, 0, 0, "Sensor threshold set to %d\n", g_ui32NVSThresholdValue);
        }
        // close the region
        NVS_close(nvsHandle);
    }

}
In the moment of write, the NVS_write function returns with -1 and no data is stored on flash. I'm using the SimpleLink MSP432P4 SDK 3.20.0.06.
Can someone help me with this issue?
Thank you,
Eugenio Penate

 
 

vNVSThreshold_loadInitial();


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>