当前位置:网站首页>M-arch (yateli M4) [at-start-f425 evaluation] No.05 flash
M-arch (yateli M4) [at-start-f425 evaluation] No.05 flash
2022-06-09 22:34:00 【Lord rolling God】
Preface
Today this is flash Reading and writing tests for ,AT32F425R8T7-7 Have 64K Of flash Space .
Flash memory structure
Flash controller (FMC), It provides all the functions required by on-chip flash memory . generally speaking ,MCU Of Flash Include 4 Parts of :
- Main storage (Main memory), Its characteristic is readable and writable , Stored is the program ; If there is enough space , It can also be used to store data ( Parameters , Records, etc. ).
- System storage area (System memory), Some translations are called memory blocks , It's actually Boot Loader, read-only .
- One time storage area OTP(One Time Program), It is characterized by only 1 Written as 0, Not by 0 Written as 1, Can be used to store protective or anti-counterfeiting content .
- Option bytes (Option bytes), It stores some configuration data of the system , Load into register at power on .
Flash The reading and writing process and precautions are clearly written in the chip manual , I won't go into that ; If you're interested , You can face the manufacturer's API The interface is better than looking at , It would be better to understand .
AT32F425 Flash structure
stay flash In the private name of the partition , Remember that the following formula can be well understood :
page (Page)< A sector (Sector) < block (Block,bank)< chip (Chip)
Generally, paging is the one with small capacity , Large capacity is divided into blocks + A sector .
FMC test
FMC The operation of is actually relatively simple , From the manufacturer API Are very mature , A few points to be noted :
- FMC You can't “ commit suicide ”, That is, it can't be written by the program itself , therefore FMC Can only write non program area Flash.
- FMC Operation needs to be carried out first unlock, After the operation, remember lock.
Code :
#ifdef AT32
#define fmc_sector_erase flash_sector_erase
#define fmc_unlock flash_unlock
#define fmc_lock flash_lock
#define fmc_word_program flash_word_program
#endif
static void fmc_test(void)
{
#ifdef FMC_TEST
#define FMC_TEST_DATA_COUNT 5
static uint8_t fmc_test_flag = 0;
uint32_t index = 0;
#if defined(GD32)
uint32_t addr = 0x08100000;
uint32_t sector = CTL_SECTOR_NUMBER_12;
#endif
#if defined(GD32M0)
uint32_t addr = 0x0803E000;
uint32_t sector = addr;
#define fmc_sector_erase fmc_page_erase
#endif
#ifdef STM32
uint32_t addr = 0x08040000;
uint32_t sector = addr;
#endif
#ifdef AT32
uint32_t addr = 0x0800FC00;
uint32_t sector = addr;
#endif
uint32_t *pdata = (uint32_t *)addr;
int32_t fmc_state;
if (fmc_test_flag)
{
return;
}
fmc_test_flag = 1;
/* 1. before erase */
printf("before erase,\tdata = ");
for (index = 0; index < FMC_TEST_DATA_COUNT; index++)
{
printf("0x%X ", pdata[index]);
}
printf("\r\n");
/* 2. after erase */
fmc_unlock();
fmc_state = fmc_sector_erase(sector);
fmc_lock();
printf("after erase[%d]\tdata = ", fmc_state);
for (index = 0; index < FMC_TEST_DATA_COUNT; index++)
{
printf("0x%X ", pdata[index]);
}
printf("\r\n");
/* 2. after program */
fmc_unlock();
for (index = 0; index < FMC_TEST_DATA_COUNT; index++)
{
fmc_state = fmc_word_program(addr, index+9);
addr += 4;
printf("programing [0x%0X] state = [%d]\r\n", addr, fmc_state);
}
fmc_lock();
printf("after program,\tdata = ");
for (index = 0; index < FMC_TEST_DATA_COUNT; index++)
{
printf("0x%X ", pdata[index]);
}
printf("\r\n");
#endif
}
test result (AT32F425, The return value of normal state is 3):
before erase, data = 0x9 0xA 0xB 0xC 0xD
after erase[3] data = 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
programing [0x800FC04] state = [3]
programing [0x800FC08] state = [3]
programing [0x800FC0C] state = [3]
programing [0x800FC10] state = [3]
programing [0x800FC14] state = [3]
after program, data = 0x9 0xA 0xB 0xC 0xD
OTP and OB
adopt Keil You can view the debugging function of Flash Address data , Of course, it can also be read directly in the program .
AT32F425 The address range of is 0x1FFFF800 – 0x1FFFF9FF, The specific viewing results are slightly .
边栏推荐
猜你喜欢
![[image segmentation] image segmentation based on anisotropic thermal diffusion equation with matlab code](/img/ea/559f338b533764c7350e40a25cebd6.png)
[image segmentation] image segmentation based on anisotropic thermal diffusion equation with matlab code

如何实现高效的IM即时通讯长连接自适应心跳保活机制

Veracrypt create file type encrypted volume

On a machine with 4GB of physical memory, how about applying for 8g of memory?

St link V2 Download: internal command error & error: flash download failed - target DLL has been canceled

AQUANEE将在近期登陆Gate以及BitMart,低位布局的良机

86. (leaflet house) leaflet military plotting - collection of linear arrows

Digital supervision of construction sites and the wisdom of scientific warfare

Industrial Internet + Digital Integrated Management cloud platform for hazardous chemical safety production

Find My产品|新款TWS耳机支持Find My功能,苹果Find My在第三方厂家应用更广泛
随机推荐
Pi of C language test question 162
Bonner visual lens lcf08lk1f
[the second revolution of report tools] optimize report structure and improve report operation performance based on SPL language
[translation paper] a progressive morphological filter for removing nonground measurements from airport lidar dat
IAR open project compilation unresponsive, stuck & stm32cubemx error generating project
Basic query statement
Diligence from childhood
Rotation of AVL tree
【BP预测】基于Adaboost的BP神经网络实现数据回归预测附matlab代码
Digital supervision of construction sites and the wisdom of scientific warfare
M-Arch(雅特力M4)【AT-START-F425测评】No.04 CRC
Huawei device configuration hub and spoke
15省份发布2021年平均工资,这些行业有“钱途”
【图像重建】基于正则化的图像超分辨重建附matlab代码
关于mongodb的那些安装、配置、报错处理、CRUD操作等再总结
【图像加密解密】基于混沌序列结合DWT+SVD实现图像加密解密(含相关性检验)含Matlab源码
Learning records of thread pool
Veracrypt create file type encrypted volume
Maximum value and subscript of acquisition matrix of C language test question 168
Calculation of C language test question 163 the day of a certain day is the day of the corresponding year, and the total number of days in the year; Calculates the number of days between two dates. Th