2022-08-25 12:21 AM
Here is my code : ignore the led toggles , the screenshot of the sr reg is below and highlited bits. Im guessing it has something to to with the arhitecture of the cpu.
Kind regards.
void flash_page_write(void)
{
uint32_t addrr_start=0x08001000;
uint32_t addrr_end=0x08001FFF;
static const uint64_t Data64_To_Prog[32] = {
0x0000000000000000, 0x1111111111111111, 0x2222222222222222, 0x3333333333333333,
0x4444444444444444, 0x5555555555555555, 0x6666666666666666, 0x7777777777777777,
0x8888888888888888, 0x9999999999999999, 0xAAAAAAAAAAAAAAAA, 0xBBBBBBBBBBBBBBBB,
0xCCCCCCCCCCCCCCCC, 0xDDDDDDDDDDDDDDDD, 0xEEEEEEEEEEEEEEEE, 0xFFFFFFFFFFFFFFFF,
0x0011001100110011, 0x2233223322332233, 0x4455445544554455, 0x6677667766776677,
0x8899889988998899, 0xAABBAABBAABBAABB, 0xCCDDCCDDCCDDCCDD, 0xEEFFEEFFEEFFEEFF,
0x2200220022002200, 0x3311331133113311, 0x6644664466446644, 0x7755775577557755,
0xAA88AA88AA88AA88, 0xBB99BB99BB99BB99, 0xEECCEECCEECCEECC, 0xFFDDFFDDFFDDFFDD};
uint32_t src_addr = (uint32_t)Data64_To_Prog;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
FLASH_PageErase(2, 1);
while(addrr_start<addrr_end){
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, addrr_start, (uint64_t)src_addr) == HAL_OK ) {
LED_toggle(LED7);
addrr_start=addrr_start+(32*sizeof(uint64_t));
LED_toggle(LED7);
}
else {LED_toggle(LED1); HAL_Delay(1000); LED_toggle(LED1);}
}
// HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, addrr_start, (uint64_t)src_addr);
HAL_FLASH_Lock();
}
Solved! Go to Solution.
2022-08-25 05:07 AM
Thanks for the effort I have found the problem I was eracing pages wrong.
2022-08-25 03:41 AM
Hi skaur.1,
could you please give some more details about the FLASJ_PageErase function? I assume this function was written by you, since it is no HAL function.
When exactly get the error flags set? After the erase process, after the first call to HAL_FLASH_Program or later?
Best Regards
Thomas
2022-08-25 03:52 AM
Hello
the page erase function is in HAL library, all it does it erases a page of memory and puts 1 into CR->PER register. the error bits begin when the function is first called and everytime after. the trouble starts when the HAL_PROG_FUN goes in to the second case of status=WAIT_FOR_THE_LAST_OPERATION().
And yea i dont know why this seems to happen. I dont se any problems with my code and I didnt touch the hal functions.
Regards,
2022-08-25 05:07 AM
Thanks for the effort I have found the problem I was eracing pages wrong.
2022-08-25 05:18 AM
That's great to hear.:thumbs_up:
(please don't forget to mark this threas a answered)
2022-08-27 06:56 AM
The FLASH_PageErase() function is not meant to be used by the user code. User code must use the HAL_FLASHEx_Erase() function.
And the 3rd argument of the HAL_FLASH_Program() function is for a data itself, not a pointer to a data memory.