Part Number: MSP432P4111
Hi,
I need some support how to read and write from the main flash. I read some threads and all documents but I don't why it isn't working.
#define FLASH_ADR_CFG 0x0 uint8_t cfgData[4096]; void flash_rd(void){ for (int i = 0; i < 10; ++i) { Display_printf(displayHandle, 0, 0, "cfgData sram=%u flash=%u", cfgData[i], *(uint8_t*)(i+FLASH_ADR_CFG)); } } void flash_wr(void){ MAP_FlashCtl_A_unprotectMemory(FLASH_ADR_CFG,FLASH_ADR_CFG+10); if(!MAP_FlashCtl_A_programMemory(cfgData, (void*) FLASH_ADR_CFG, 4096)) { while(1); } MAP_FlashCtl_A_protectMemory(FLASH_ADR_CFG,FLASH_ADR_CFG+10); } // with button 1: for (int i = 0; i < 10; ++i) { cfgData[i] = i; } flash_wr(); // with button 2: flash_rd();
If I read the first time before writing I get (putty):
cfgData sram=0 flash=0 cfgData sram=0 flash=0 cfgData sram=0 flash=4 cfgData sram=0 flash=32 cfgData sram=0 flash=177 cfgData sram=0 flash=1 cfgData sram=0 flash=2 cfgData sram=0 flash=0 cfgData sram=0 flash=187 cfgData sram=0 flash=193
After writing I get always:
cfgData sram=0 flash=0 cfgData sram=1 flash=0 cfgData sram=2 flash=0 cfgData sram=3 flash=0 cfgData sram=4 flash=0 cfgData sram=5 flash=1 cfgData sram=6 flash=2 cfgData sram=7 flash=0 cfgData sram=8 flash=8 cfgData sram=9 flash=1
I would expect 0...9. And if reupload the code I get an error:
CORTEX_M4_0: GEL Output: Memory Map Initialization Complete
CORTEX_M4_0: GEL Output: Halting Watchdog Timer
CORTEX_M4_0: File Loader: Failed to initialize flash programming: Target failed to read 0xE004300C
CORTEX_M4_0: GEL: File: C:\...\flash_a_program_memory_MSP_EXP432P4111_nortos_ccs\Debug\flash_a_program_memory_MSP_EXP432P4111_nortos_ccs.out: Load failed.
With the next upload I don't get an error. When I see this error message I'm asking me, if this is a problem because I'm using FreeRTOS?
Thanks for any help!