目录
1.flash内存的大小
对于大多数FXXX8系列的芯片,flash的大小基本都是64k,且大容量的每页大小为2K,中小容量的每页大小为1K,当然具体的大小还是要看官方的数据手册以及参考手册。
2.flash写入的过程
(一)解锁顺序;
void FLASH_Unlock(void);//只有解锁了,内部FLASH才允许读写
/* (1) Wait till no operation is on going */
/* (2) Check that the flash memory is unlocked */
/* (3) Perform unlock sequence */
while ((FLASH->SR & FLASH_SR_BSY) != 0) /* (1) */
{
/* For robust implementation, add here time-out management */
}
if ((FLASH->CR & FLASH_CR_LOCK) != 0) /* (2) */
{
FLASH->KEYR = FLASH_FKEY1; /* (3) */
FLASH->KEYR = FLASH_FKEY2;
}
(二)对flash除保留地址及代码存储地址之外的主闪存编程顺序;
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
/* (1) Set the PG bit in the FLASH_CR register to enable programming */
/* (2) Perform the data write (half-word) at the desired address */
/* (3) Wait until the BSY bit is reset in the FLASH_SR register */
/* (4) Check the EOP flag in the FLASH_SR register */
/* (5) clear it by software by writing it at 1 */
/* (6) Reset the PG Bit to disable programming */
FLASH->CR |= FLASH_CR_PG; /* (1) */
*(__IO uint16_t*)(flash_addr) = data; /* (2) */
while ((FLASH->SR & FLASH_SR_BSY) != 0) /* (3) */
{
/* For robust implementation, add here time-out management */
}
if ((FLASH->SR & FLASH_SR_EOP) != 0) /* (4) */
{
FLASH->SR = FLASH_SR_EOP; /* (5) */
}
else
{
/* Manage the error cases */
}
FLASH->CR &= ~FLASH_CR_PG; /* (6) */
(三)按页擦除的顺序;
FLASH_Status FLASH_ErasePage(uint32_t Page_Address)
/* (1) Set the PER bit in the FLASH_CR register to enable page erasing */
/* (2) Program the FLASH_AR register to select a page to erase */
/* (3) Set the STRT bit in the FLASH_CR register to start the erasing */
/* (4) Wait until the BSY bit is reset in the FLASH_SR register */
/* (5) Check the EOP flag in the FLASH_SR register */
/* (6) Clear EOP flag by software by writing EOP at 1 */
/* (7) Reset the PER Bit to disable the page erase */
FLASH->CR |= FLASH_CR_PER; /* (1) */
FLASH->AR = page_addr; /* (2) */
FLASH->CR |= FLASH_CR_STRT; /* (3) */
while ((FLASH->SR & FLASH_SR_BSY) != 0) /* (4) */
{
/* For robust implementation, add here time-out management */
}
if ((FLASH->SR & FLASH_SR_EOP) != 0) /* (5) */
{
FLASH->SR = FLASH_SR_EOP; /* (6)*/
}
else
{
/* Manage the error cases */
}
FLASH->CR &= ~FLASH_CR_PER; /* (7) */
(四)上锁顺序;
/* (1) Set the LOCK Bit to lock the FLASH control register and program memory access */
void FLASH_Lock(void)
{
FLASH->CR |= FLASH_CR_LOCK;
}
3.flash读取的过程
uint32_t data;//用于读取flash的数据
uint32_t address;//写入的地址
data=*(uint32_t*address);//将地址中的数值赋给data
4.链接
STMCU中文官网ADF4350 pdf, ADF4350 Download, ADF4350 Description, ADF4350 Datasheet, ADF4350 view ::: ALLDATASHEET :::