#define FLASH_PAGE_SIZE ((uint32_t)0x00000800)
#define FLASH_USER_START_ADDR ((uint32_t)0x0800F800)
#define FLASH_USER_END_ADDR ((uint32_t)0x0800FFFF)
void UserWriteEeprom(void)
{
int i;
uint32_t address_t;
//Unlock the Flash to enable the flash control register access
FLASH_Unlock();
// Erase the FLASH pages
UserErase(); //FLASH_ErasePage(FLASH_USER_START_ADDR);
// Program the user Flash area word by word
address_t = FLASH_USER_START_ADDR;
for(i=0;i<4;i++)
{
FLASH_ProgramWord(address_t, CustomerSettings.DataAll[i]);
address_t += 4;
}
// Lock the Flash to disable the flash control register access (recommended
// to protect the FLASH memory against possible unwanted operation)
FLASH_Lock();
}
上面是在STM32F103的芯片上使用正常的能过保存数据到FLASH,但是用到GD32F130C8T6上,DEBUG的时候FLASH_Unlock()这个函数就通不过了,我用的是GD的库GD32F1x0_StdPeriph_Driver。
请各路大侠提点,程序是从STM32F103上移植过来的,其他的都通过了,就数据保存没发通过 |