1、在flash的前256K字节空间内,CPU执行指令零等待;在此范围外,CPU读取指令存在较长延时;
2、对于flash大于512KB(不包括等于512KB)的GD32F10x_CL和GD32F10x_XD,使用了两片闪存;前512KB容量在第一片闪存(bank0)中,后续的容量在第二片闪存(bank1)中;
3、对于flash容量小于等于512KB的GD32F10x_CL和GD32F10x_HD,只使用了bank0;
4、对 于 GD32F10x_MD , 闪 存 页 大 小 为 1KB 。 GD32F10x_CL 和 GD32F10x_HD ,GD32F10x_XD,bank0的闪存页大小为2KB,bank1的闪存页大小为4KB;
5、支持32位整字或16位半字编程,页擦除和整片擦除操作;
GD32的flash读操作
flash可以像普通存储空间一样直接寻址访问。
value=*(uint32_t*)FlashAddr;
uint16_t IAP_ReadFlag(void)
{
return *(volatile uint16_t*)(FLASH_ADDR);
}
GD32的flash擦除操作
页擦除
每一页可以被独立擦除,步骤如下:
- 确保FMC_CTLx寄存器不处于锁定状态;
- 检查FMC_STATx寄存器的BUSY位来判定闪存是否正处于擦写访问状态,若BUSY位为1,则需等待该操作结束,BUSY位变为0;
- 置位FMC_CTLx寄存器的PER位;
- 将待擦除页的绝对地址(0x08XX XXXX)写到FMC_ADDRx寄存器;
- 通过将FMC_CTLx寄存器的START位置1来发送页擦除命令到FMC;
- 等待擦除指令执行完毕,FMC_STATx寄存器的BUSY位清0;
-
如果需要,使用DBUS读并验证该页是否擦除成功。
代码上直接调用GD的库函数即可:void fmc_erase_page(uint32_t Page_Address) { fmc_unlock(); //fmc解锁 /* clear all pending flags */ fmc_flag_clear(FMC_FLAG_BANK0_END); fmc_flag_clear(FMC_FLAG_BANK0_WPERR); fmc_flag_clear(FMC_FLAG_BANK0_PGERR); /* erase the flash pages */ fmc_page_erase(Page_Address); /* clear all pending flags */ fmc_flag_clear(FMC_FLAG_BANK0_END); fmc_flag_clear(FMC_FLAG_BANK0_WPERR); fmc_flag_clear(FMC_FLAG_BANK0_PGERR); fmc_lock(); //fmc上锁 }
要擦除连续的几页:
void fmc_erase_pages(void) { uint32_t erase_counter; /* unlock the flash program/erase controller */ fmc_unlock(); /* clear all pending flags */ fmc_flag_clear(FMC_FLAG_BANK0_END); fmc_flag_clear(FMC_FLAG_BANK0_WPERR); fmc_flag_clear(FMC_FLAG_BANK0_PGERR); /* erase the flash pages */ for(erase_counter = 0; erase_counter < page_num; erase_counter++){ fmc_page_erase(FMC_WRITE_START_ADDR + (FMC_PAGE_SIZE * erase_counter)); fmc_flag_clear(FMC_FLAG_BANK0_END); fmc_flag_clear(FMC_FLAG_BANK0_WPERR); fmc_flag_clear(FMC_FLAG_BANK0_PGERR); } /* lock the main FMC after the erase operation */ fmc_lock(); }
整片擦除
void fmc_erase_page(uint32_t Page_Address) { fmc_unlock(); //fmc解锁 /* clear all pending flags */ fmc_flag_clear(FMC_FLAG_BANK0_END); fmc_flag_clear(FMC_FLAG_BANK0_WPERR); fmc_flag_clear(FMC_FLAG_BANK0_PGERR); /* erase whole chip */ fmc_mass_erase(); /* clear all pending flags */ fmc_flag_clear(FMC_FLAG_BANK0_END); fmc_flag_clear(FMC_FLAG_BANK0_WPERR); fmc_flag_clear(FMC_FLAG_BANK0_PGERR); fmc_lock(); //fmc上锁 }
## GD32的flash写操作
往flash的某个地址写入数据前,一般要先擦除该地址。
16位半字编程:
void IAP_WriteFlag(uint16_t flag)
{
fmc_unlock();
fmc_page_erase(IAP_FLAG_ADDR);
fmc_halfword_program(IAP_FLAG_ADDR,flag);
fmc_lock();
}
32位整字编程:
void fmc_program(void)
{
/ unlock the flash program/erase controller /
fmc_unlock();
address = FMC_WRITE_START_ADDR;
/* program flash */
while(address < FMC_WRITE_END_ADDR){
fmc_word_program(address, data0);
address += 4;
fmc_flag_clear(FMC_FLAG_BANK0_END);
fmc_flag_clear(FMC_FLAG_BANK0_WPERR);
fmc_flag_clear(FMC_FLAG_BANK0_PGERR);
}
/* lock the main FMC after the program operation */
fmc_lock();
}
————————————————
原文链接:https://blog.csdn.net/qlexcel/article/details/118531806
————————————————
原文链接:https://blog.csdn.net/qlexcel/article/details/118531806
I am also commenting to let you be aware of what a incredible discovery my cousin’s daughter encountered checking the blog. She came to understand numerous details, not to mention how it is like to have a very effective helping heart to get the mediocre ones just grasp various tortuous subject areas. You actually surpassed readers’ expectations. Thanks for imparting these powerful, healthy, educational and even unique guidance on your topic to Mary.
Simply a smiling visitant here to share the love (:, btw outstanding design and style. “Everything should be made as simple as possible, but not one bit simpler.” by Albert Einstein.
Dear immortals, I need some wow gold inspiration to create.
Useful info. Lucky me I discovered your website by accident, and I am stunned why this accident did not took place earlier! I bookmarked it.
Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.
First off I would like to say superb blog! I had a quick question in which I’d
like to ask if you don’t mind. I was curious to find
out how you center yourself and clear your head before writing.
I have had a tough time clearing my mind in getting my thoughts out there.
I truly do enjoy writing but it just seems like the first
10 to 15 minutes are lost just trying to figure out how
to begin. Any ideas or hints? Cheers!
Hey! Do you know if they make any plugins to safeguard against hackers?
I’m kinda paranoid about losing everything I’ve worked hard
on. Any tips?
Greetings! Very useful advice in this particular article!
It’s the little changes that produce the largest changes.
Many thanks for sharing!
I must voice my admiration for your kindness for individuals that really need guidance on this one situation. Your real commitment to getting the solution up and down became definitely invaluable and have helped others just like me to arrive at their objectives. Your own insightful key points denotes a whole lot a person like me and a whole lot more to my mates. With thanks; from each one of us.
My spouse and I stumbled over here from a different web address and thought I may as well check things out.
I like what I see so now i’m following you.
Look forward to finding out about your web page for a
second time.
But wanna input that you have a very nice web site, I enjoy the layout it really stands out.
El monitoreo de teléfonos celulares es una forma muy efectiva de ayudarlo a monitorear la actividad del teléfono celular de sus hijos o empleados. https://www.xtmove.com/es/how-to-install-spy-app-to-monitor-another-phone-for-free/
284100 341165I needs to spend some time learning more or figuring out more. Thanks for fantastic information I was in search of this info for my mission. 723512
At present, remote control software is mainly used in the office field, with basic functions such as remote file transfer and document modification.
viagra tthighereduhryyy.SX8FJjBOFLD
541728 432321Which is some inspirational stuff. Never knew that opinions may be this varied. Thank you for all of the enthusiasm to give such beneficial data here. 754720
909802 298658Wow, incredible weblog layout! How long have you been blogging for? you make blogging look easy. The overall look of your internet site is excellent, as properly as the content material! xrumer 24527
Very good website. It’s awesome. I’ll keep it up. บาคาร่าออนไลน์
It’s awesome. I’ll keep it up. บาคาร่าออนไลน์
683695 171375I dugg some of you post as I thought they were handy really useful 287962
Você pode usar o software de gerenciamento dos pais para orientar e supervisionar o comportamento dos filhos na Internet. Com a ajuda dos 10 softwares de gerenciamento de pais mais inteligentes a seguir, você pode rastrear o histórico de chamadas de seu filho, histórico de navegação, acesso a conteúdo perigoso, aplicativos que eles instalam etc.
Tremendous things here. I’m very glad to peer your
post. Thank you so much and I’m looking forward to contact you.
Will you kindly drop me a e-mail?
Wow, wonderful blog layout! How lengthy have you ever been running a blog for?
you make running a blog glance easy. The whole glance of your web
site is magnificent, as smartly as the content material!
You can see similar here ecommerce
Wow, superb blog format! How long have you been blogging for?
you make running a blog glance easy. The full glance of your site is fantastic, let alone the content
material! You can see similar here dobry sklep
508767 258903Ill create a hyperlink towards the web page about my private weblog. 177997
754604 980409I agree along with your points , great post. 96431
173016 583184Thank you for your very good data and feedback from you. car dealers san jose 52562
769064 952416Numerous thanks for the wonderful post C Id enjoyable reading it! That i adore this blog. 720548
377803 358800Yay google is my king assisted me to locate this outstanding web site! . 735499
236556 198232you use a amazing weblog here! do you wish to have the invite posts in my small weblog? 46495
261332 432232Dude.. My group is not considerably into looking at, but somehow I acquired to read several articles on your blog. Its amazing how intriguing its for me to go to you fairly often. 944593
Hi, I log on to your new stuff regularly. Your writing style is awesome, keep it up!
247240 30475I likewise believe thus, perfectly pent post! . 127098
Wonderful work! That is the type of information that are supposed to be shared across the web.
Disgrace on the seek engines for no longer positioning this publish higher!
Come on over and discuss with my site . Thank you =)
122227 603417As soon as I discovered this site I went on reddit to share some with the adore with them. 161964
132571 990602If running proves to be a difficulty then it may be wise to locate alternative exercises such as circuit training, weight training, swimming or cycling. 907965
137399 878391Its actually a cool and helpful piece of details. Im glad that you shared this helpful information with us. Please keep us informed like this. Thanks for sharing. 23522
671302 678899Youre so cool! I dont suppose Ive read anything in this way before. So good to uncover somebody with some original suggestions on this topic. realy appreciate starting this up. this excellent site is something that is necessary more than the internet, a person if we do originality. valuable work for bringing something new towards the web! 694256
330630 159870How may be the new year going? I hope to read more fascinating posts like last year 583016
854846 352530I ought to appear into this and it would be a difficult job to go over this completely here. 324129
549373 50385Hey! I simply wish to give an enormous thumbs up for the great information youve got here on this post. I will likely be coming back to your weblog for more soon. 953431
87908 438904Glad to be 1 of a lot of visitants on this awesome site : D. 984820
71033 361547Aw, this was a actually good post. In concept I wish to put in writing like this in addition ?taking time and actual effort to make an outstanding write-up?nonetheless what can I say?I procrastinate alot and by no means seem to get something done. 382546
54011 114091Take a peek at the following tips what follows discover perfect strategy to follow such a mainly because you structure your small business this afternoon. earn dollars 808410
how to buy priligy in usa I had so many questions about acupuncture and he answered all of them and explained them completely
Very interesting points you have noted, thankyou for posting. “There is nothing in a caterpillar that tells you it’s going to be a butterfly.” by Richard Buckminster Fuller.
Monitor Closely 1 diazepam and trifluoperazine both increase sedation priligy pills