Hello everyone.
I need your help to understand a weird behavior here. I have a project based on simple_peripheral_oad_offchip (SDK simplelink_cc13xx_cc26xx_sdk_7_10_00_98).
int_fast16_t ret; uint8_t buf_write[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; uint8_t buf_read[20]; NVS_Handle nvsHandle; NVS_Attrs regionAttrs; NVS_Params nvsParams; NVS_init(); NVS_Params_init(&nvsParams); nvsHandle = NVS_open(CONFIG_NVSEXTERNAL, &nvsParams); if (nvsHandle == NULL) { while(1) {}; } NVS_getAttrs(nvsHandle, ®ionAttrs); ret = NVS_read(nvsHandle, 0x80000, buf_read, 20); ret = NVS_erase(nvsHandle, 0x80000, EFL_PAGE_SIZE); ret = NVS_read(nvsHandle, 0x80000, buf_read, 20); ret = NVS_write(nvsHandle, 0x80000, buf_write, 10, NVS_WRITE_PRE_VERIFY | NVS_WRITE_POST_VERIFY); ret = NVS_read(nvsHandle, 0x80000, buf_read, 20); ret = NVS_write(nvsHandle, 0x8000A, buf_write, 10, NVS_WRITE_PRE_VERIFY | NVS_WRITE_POST_VERIFY); ret = NVS_read(nvsHandle, 0x80000, buf_read, 20); NVS_close(nvsHandle); while(1) {};
The code above works successfully. But when I replace it with the code below (flash_interface) I have problem with flash_write
int_fast16_t ret; uint8_t buf_write[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; uint8_t buf_read[20]; flash_init(); if (flash_open()) { if (readFlash(0x80000, buf_read, 20) != FLASH_SUCCESS) { while(1) {}; } if (eraseFlashPg(EXT_FLASH_PAGE(0x80000)) != FLASH_SUCCESS) { while(1) {}; } if (readFlash(0x80000, buf_read, 20) != FLASH_SUCCESS) { while(1) {}; } if (writeFlash(0x80000, buf_write, 10) != FLASH_SUCCESS) { // spin here while(1) {}; } if (readFlash(0x80000, buf_read, 20) != FLASH_SUCCESS) { while(1) {}; } if (writeFlash((uint_least32_t)0x8000A, buf_write, 10) != FLASH_SUCCESS) { while(1) {}; } if (readFlash(0x80000, buf_read, 20) != FLASH_SUCCESS) { while(1) {}; } flash_close(); } else { while(1) {}; } while(1) {};
In the first flash_open() call the program raises an error :
if (Error_policy_D == Error_SPIN) { for(;;) { } }
Why I get that error using the interface?