Error Writing 64 bit in FLASH
Tranferring data from serial input,(in my case idDA), or from an SD, may be you try to write a double word a time (64bit) in flash area and you may use the:
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, flash_ptr,codeData64). This function calls the
static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data);
(file stm32F4xx_hal_flash.c);
but the system signals TWO errors :
PGSERR: Programming sequence error
Set by hardware when a write access to the Flash memory is performed by the code while the control register has not been correctly configured.
PGAERR: Programming alignment error
Set by hardware when the data to program cannot be contained in the same 128-bit Flash memory row.
mmm....
There is a little bug , as you can see.....
static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data)
{
/* Check the parameters */
assert_param(IS_FLASH_ADDRESS(Address));
/* If the previous operation is completed, proceed to program the new data */
CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
//FLASH->CR |= FLASH_PSIZE_DOUBLE_WORD; <<<<<<<<<<<------------------- HEY!!!
FLASH->CR |= FLASH_PSIZE_WORD; <<<<<<------- NEW VERSION
FLASH->CR |= FLASH_CR_PG;
/* Program the double-word */
*(__IO uint32_t*)Address = (uint32_t)Data;
*(__IO uint32_t*)(Address+4) = (uint32_t)(Data >> 32);
}
You are NOT writing a DuobleWord but TWO TIMES a word.....
Have a happy new year.
