求助采用STM32G473CBT6, 写片内FLASH失败,代码如下:
//.ROM_D0 :ER_IROM1 0x08000000 0x00020000
__attribute__((section(".ROM_D0"))) static uint64_t Key_Flash=(uint64_t)(-1);
__IO uint64_t Key_ID=0x1234567812345678;
__HAL_FLASH_PREFETCH_BUFFER_DISABLE(); //关闭FLASH预取缓冲区
if((uint64_t)(-1)==Key_Flash)
{
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, (uint32_t)&Key_Flash, Key_ID);
HAL_FLASH_Lock();
}
|