Stm32f0xx_flash programming (on-chip) configuration detailed procedures

Source: Internet
Author: User

, overview

Regarding the storage of the data, I think the programmer will basically use it, just to see where you store it. STM32 the inside of the chip FLASH can be programmed, which means that data can be stored. However, many do small application development of people do not take advantage of this feature, but instead of a separate EEPROM or FLASH, I think in some cases (small data, Not often changed) this is a huge waste of resources.

about using internal flash programming, and many people on the internet say: 1 , internal flash 2 , internal flash It destroys the program. These assertions do exist for some reason, for the number of times, 10w times, I think this number of times unless you often write flash Under normal circumstances you cannot reach this value. This is not a problem if you have a rigorous programming program for sabotage. In conclusion, I think these are not worrying problems, so long as you make good use of the process, so that you can take advantage of good resources.

To cite an example, I developed three years ago on the stm32f1 two products (already put into use), the amount of data stored in a nearly 6K , each use, read and write the number of almost 5-10 , but the product has not yet FLASH and there have been problems. Therefore, the use of good resources is also a software engineer to consider.

Tip: For security reasons, write the number of times best to make an estimate, the stored address and the program has a certain distance.

based on the principle of free sharing, convenient for everyone to learn knowledge on mobile phones, sharing technical knowledge every day.  If you feel that the content you share is useful to you and you want to learn more about it, please use the search "embedddeveloper" or scan the following QR code, attention, there will be more exciting content waiting for you.

Ⅱ, download

The article provides the "Software engineering" are on the hardware board to conduct multiple tests, and ensure that no problem before uploading to 360 cloud disk, please feel free to download the test, if there is a problem, please check your board if there is a problem.

St Standard Peripheral Library and reference manuals, data sheets, etc. can be downloaded from the St official website , you can also go to my 360 cloud disk download. There are several versions of the reference manual for the F0 series of chips (for F0 different chips), but there is a generic version, which is "stm32f0x128 reference manual V8 (English) 2015-07" recommended reference to this manual, later if you switch to a type of chip is also easy to understand.

Today's Software engineering (360 cloud disk):

Https://yunpan.cn/cRAK2gWXyJZXD Access Password

STM32F0XX information can be downloaded from my 360 cloud disk:

https://yunpan.cn/cS2PVuHn6X2Bj access password 8c37

Ⅲ, preparatory work

For internal FLASH Programming, we recommend that you prepare F0 Reference manuals and data sheets for easy access to relevant knowledge, no please go to St official website or to my Cloud Disk download.

Today's summary of software engineering is based on the "TIM Basic Delay configuration Detailed process" modified, so you need to prepare the software engineering download. I always provide a tidy software for everyone to download, but if you are a learner, it is recommended that you do one step at a time: Open Project -- new file (flash.c flash.h)- > add related files to the project, Add source code.

Ⅳ, flash Span style= "font-family: the song Body;" > programming instructions

STM32F0 Series chip in the size of the page is regular, that is, 1K or 2K size (f0_flash), People who have studied other series of chips may know that there are not rules in many other chips, such as F2andF4 , which are not regular (F4_flash ), some piece 16K , 128K and so irregular. Such a chip is not applicable to the works offered today, and today offers a project for internal FLASH Rules of the size of the chip.

Figure:F0_flash

Figure:F4_flash

Ⅴ, code description

Engineering Summary Description : The source code for the project is mainly two interfaces, one write, one read.

void Flash_writenword (uint16_t* pbuffer, uint32_t writeaddr, uint16_t Nword);

void Flash_readnword (uint16_t* pbuffer, uint32_t readaddr, uint16_t Nword);

Believe that the regular programming people understand the meaning of the function interface (my naming rules are more humane), and common access to external flash, not overwrite the data, I have been applied in the actual work and commercialized.

Mainly in the address "ADDR" to write a flag bit, in the address "ADDR + 1" to write a string of data consecutively. If the flag bit is already "written", then the data will not be written again, only the data will be read, meaning that the data is only written once, and then each time just read the data (is to ensure that the data will be lost after the power loss). Each time the data is read, the data written by the serial port is printed correctly.

Provide the project with simple as the principle, detailed Chinese notes, convenient for everyone.

① Read Function interface

The function is located under the Flash. c file;

This function interface is relatively simple, direct address read data.

Attention:

A. The parameter pbuffer is a data buffer, which is 16 bits, not 8 bits. (In fact, this can be organized into 8-bit, due to limited time, post-collation).

B. The parameter length is also the number of 16 bits.

C. Address is the internal flash address, do not overflow, and do not conflict with the program storage address. It's best to look at your program size and chip capacity.

② Write Function interface

The function is located under the Flash. c file;

This function interface Flash_writenword is the focus of this article , because the writing here does not destroy other data (even near the address), this function interface is more readily available, that is, the application-level interface. After my extensive testing and project development, no bugs were found.

③ Focus

A. Page size: STM32F0 due to chip model differences Please note the size of the page, and I use a macro in the program to define the size as well.

Ⅵ, description

Perhaps your hardware chip is not to provide the chip inside the project, but stm32f0 chip software compatibility is very good, can be applied to F0 many other models of chips, even F2, F4 and other chips (see the manual, or personally test).

The software engineering provided in this article is based on the St standard Peripheral Library, rather than using STM32CUBEMX to establish the project. Personally feel that using ST's standard Peripheral library suitable for learners, STM32CUBEMX building engineering structure complex, for learners, especially beginners are estimated to be headache.

Today's project is based on the project "stm32f0xx_tim Basic Delay configuration Detailed process" modified, the above examples are summarized for reference only, if there is wrong, please understand.

Ⅶ, last

Attention, reply to "more content", will get more content (such as:UCOS instances, etc., constantly updated in ...) )。

If you like what I share, and you want to know more about it, please follow the public number at the beginning of the article, the new content continues to be updated, and more exciting content will appear later.

Stm32f0xx_flash programming (on-chip) configuration detailed procedures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.