STM32F0XX_DMA Transceiver Usart Data Configuration detailed procedure

Source: Internet
Author: User



Objective



About the function of DMA (Direct Memory Access), the people who are concerned about me should know that I have briefly spoken on the F1 chip. There are netizens asked to explain in F0 the use of DMA transceiver serial data. Today should be a user request to summarize on the F0 chip, the use of DMA transmission (transceiver) Usart data functions.



In a variety of chips (F0, F1, F2, F3, F4) know the function of the DMA module friends may find a feature, is that the DMA function has a lot of similar places, even the same. In fact, each module in different series of chips (even different vendors) is basically the same, this is called comprehend by analogy. The same is true for software development, when you learn the development of a language, it is easy to get in touch with the development of other languages. Here I would like to say, in fact, I am most of St Chip (full range of chips STM8, STM32) have known, many are similar, as long as there is time, the latter will summarize the STM8 development of the article. Of course, more exciting content will also appear (such as: Ucos OS, etc.).



The functions and uses of DMA are not described here, and today the focus is on querying how to summarize stm32f0xx using DMA to send and receive Usart data configuration details process. In addition to provide a interrupt mode using DMA to send and receive Usart data software engineering, interested friends please download the software Engineering source code for research.






based on the principle of free sharing, If you feel that sharing content is useful to you, please Follow the public number " Embedddeveloper "There are many more wonderful content waiting for you.





Download



St Standard Peripheral Library and reference manuals, data sheets, etc. can be downloaded from the St official website , you can also go to my 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 (cloud disk):



Query method:



https://yunpan.cn/cSbcTa9ijncY2 access Password 152a






Interrupt mode:



https://yunpan.cn/cSbc7T4cxqWah access password 7e7f






STM32F0XX information can be downloaded from my cloud disk:



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






Preparatory work



On the basis of yesterday's software engineering, create new source program Files (DMA.C and Dma.h), add new source program files to the project DMA.C and use to the standard peripheral library STM32F0XX_DMA.C. How to add source files in a project see the previous article "Stm32f0_ new software engineering detailed procedures", adding complete such as:






Attention:



The location of the file is the best corresponding directory, easy to manage. For example: DMA.C is placed under the BSP file and added below the BSP group in the project.






Principle of data transmission



DMA is a module controller that exchanges data between memory (such as an array) and peripherals (such as USART, ADCs, and so on). It is also possible to see the principle of the entire module data transmission from the DMA System Block diagram (). There are a few things to note about the DMA module in the F0 chip, please see the final point.









Configuration process Details



①RCC Clock






The function is located under the BSP. c file;



I'm personally accustomed to the first step of configuring the clock, ST 's officially provided routines also put the configuration clock in front. The configuration of the RCC clock is important, several times I just because I did not configure the corresponding RCC clock, let me find a long time problem, finally found that is RCC The clock is not configured.



Attention:



Peripheral clocks should not be arbitrarily added, such as:RCC_APB1 Peripherals do not configure in the rcc_apb2 Clock " such as:Rcc_apb2periphclockcmd (RCC _AHBPERIPH_DMA1, ENABLE); This can be compiled, but the wrong "



I warn the RCC clock every time because many people are having trouble with the software because of the clock, so remind more people to be careful about configuring RCC.






Configuration of ②DMA transmission (memory-and peripherals)






The function is located under the DMA. c file;



Key notes:



1, Transmission direction: Here is the memory (array ) and peripherals (serial port);



2, Channel: Use MDA1 channel 2(serial port send).






Configuration of ③DMA transmission (peripheral-memory)






The function is located under the DMA. c file;



The difference between these two function interfaces is the same as those noted above.






④DMA the effect of transmitting serial port






The function is located under the main. c file;



This is the effect function that actually runs.



1, power on the transmission of data "Dma_start ... ";



2, waiting to receive the data (DMA mode to receive the data of ten bytes);



3, DMA mode to send the bytes of data, waiting to send the completion.



4, sequentially cycle down.






Today's focus



A, the choice of channel



Because F0 chip some chip only DMA1, have no DMA2, some DMA1 have 5 Channel, some DMA1 have 7 channels, which need to be configured according to the manual for the model, here can not select the error, otherwise you cannot use DMA function.






B, the length of the transmission



Since the maximum number of transfers is 65536, in the actual project development, there may be more data to be transmitted, then separate transmission is required.



C, transmission data width



The width of the data if the transmission of the same between the two, in fact, there is no need to pay attention. However, if the data width is different, here you need to pay attention to, specifically see the manual, here is just put forward to be the focus, interested friends please do their own research ah.









Description



STM32F0 's Chip software is well-compatible and can be applied to Many other models of F0 (see Manual, or test it yourself).



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.









At last



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.






Read the original






STM32F0XX_DMA Transceiver Usart Data Configuration detailed procedure


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.