cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_FLASH_Program always return error code 0x06

chief
Associate II
Posted on March 30, 2015 at 15:44

I use STM32F417IG

Minimal example of code:

uint32_t startAddress = 0x80E0000;

static uint32_t mSize =0x13;//

char test_string[13]={''Hello World.''};

HAL_FLASH_Unlock();

for(uint32_t i=0;i<mSize;i++)

{

status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, startAddress+i,test_string[i]);

if(status==HAL_ERROR)

{

printf(''Flash error code: %d for data index %d\n'',HAL_FLASH_GetError(),i);//Always return 6

}

}

What is wrong?

#flash #hal #stm32
2 REPLIES 2
Posted on March 30, 2015 at 21:24

Dunno, what's 6 defined as meaning, and is the memory erased, check the bytes are 0xFF

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chief
Associate II
Posted on March 31, 2015 at 07:11

#define HAL_FLASH_ERROR_PGS          ((uint32_t)0x00000002)    /*!< Programming Sequence error    */

#define HAL_FLASH_ERROR_PGP          ((uint32_t)0x00000004)    /*!< Programming Parallelism error */

Sector 12 (0x080E000 - 0x080FFFFF) filed by 0xff. I try to fully erase chip by j-link flashing device. No any changes.