Article count:10827 Read by:13690842

Featured Content
Account Entry

[MSP430 Fun Talk] MSP430 Lecture 13: Application of DMA

Latest update time:2016-04-19
    Reads:

After twelve lectures on 430, I believe everyone can understand the specific usage of a single-chip microcomputer, and there are still many details to be understood. However, for basic applications, we can basically do it through twelve lectures, but there may still be many problems in actual use. However, through these twelve lectures, we can master the methods of learning and solving problems, so practical application is not difficult.

This series of tutorials is almost coming to an end. There will be a few more lectures. If possible, we will also attach a specific case to show how to apply the 430 product. We will also explore its low power consumption characteristics in more depth.



Today we will continue to discuss the use of 430 peripherals. Today we are talking about the DMA module. First of all, we need to know what DMA is?

DMA stands for Direct Memory Access, which means direct memory access. So what does it mean? Let's explain.


For example, if we need to read a piece of data, simply put, read the level of a voltage from an IO port and store it in a variable, then in the absence of DMA, it is generally divided into the following steps:

1. First, the CPU performs a read operation to read the contents of the IO input register into the memory

2. Then write the contents of the memory into the variable through the CPU


That is to say, in this case, the reading of a register requires the participation of the CPU, which takes up the CPU's running time. When we add the DMA module, what function will we achieve?

That is to say, by using the DMA module, we do not need to involve the use of the CPU. As long as the DMA channel is set up, the data will be directly transferred to the specified storage unit through the register, thereby saving the CPU running time and greatly improving efficiency.


Let's take a more practical example. For example, if you want to sell something, such as books, you need to go to a book distributor to get the goods, then set up a store, and then sell the books to others. This is the whole process. Now if you have the "DMA" function, you don't need to open a store. You can just call the distributor and ask him to send the books to the customer. You don't need to open a store to sell them yourself. The process of calling is the same as the configuration of our DMA. We must go through a configuration process before using it.


It is very clear that if the DMA channel can be used, it will be of great help in improving the running speed.

Next, let's take a look at the DMA introduction of FR5969:

The DMA features of FR5969 include the following:

1. Up to 8 independent transmission channels

2. Configurable DMA channel priority

3. Only two MCLK clock cycles are required to perform a conversion

4. One byte, two bytes or mixed byte and word conversion is supported

5. A maximum of 65535 bytes or words can be stored

6. Configurable conversion trigger mode

7. Four address modes

8. Single, block, or multi-block transfer mode

Here we add an explanation of the difference between word and byte:

Byte is what we call byte, there is no doubt that 8 binary bits represent one byte. As for word, it is related to our CPU architecture. For 16-bit architecture, one word is 2 bytes, 32-bit is 4 bytes, and 64-bit is 8 bytes. So it is easy to see that one word is the maximum amount of data that can be transmitted at one time by the bus of a CPU architecture, so here we can understand one word very well. For MSP430FR5969, it is a 16-bit microcontroller, so its word represents two bytes.


So let's take a general look at these features first, and then we will discuss the entire configuration process in detail.

First, let's look at the address mode of the DMA channel. There are four modes for 430, as follows:

From the figure we can easily see the difference between these four address modes. The first is single address to single address, the second is single address to block address, the third is block address to single address, and the fourth is block address to block address.

Then the following is our transmission mode:

The first part is the control bit information (DMADT control bit, this bit must be in a DMA control register). There are 6 transfer modes in total.

Single transmission mode requires trigger transmission each time.

In block transfer mode, a block of data is transmitted simultaneously in a single trigger.

In burst block transfer mode, the CPU is in indirect working state and cross-working in block transfer mode.

Repeat single transfer mode, that is, transfer automatically.

Repeated block transfer mode also implements automatic transmission, and the rest is the same as above.

The repeated burst block transmission mode is the same as above, but it can be automatically repeated without software triggering.


The above is a basic introduction to the DMA module. You can learn about the relevant features and some of the transmission methods it can support. The manual gives the specific operation methods of each transmission method. However, due to the length of the manual, we cannot explain them one by one. If you need to use them, you can refer to the manual for details. We will only introduce one method here.


We assume that there are two arrays, one array contains the string hello world! and the other string is empty. Then we use DMA to send the data of Data1 to Data2. In the process, we need to use the block transmission method, because our string has a total of 11 bytes. If we use the single transmission mode, we can only transmit a word of 2 bytes at most. This should be easy to understand. In addition, we use software to trigger the data transmission, and then we compare whether the two strings are the same. If they are the same, LED2 on the board will be lit.

The idea of ​​the whole code is like this, the specific code is as follows:

To determine whether two strings are equal, we use a function, strcmp, which is a function in the C language library. It is used to determine whether the strings are equal. The parameters can be directly input with the first address of the two strings. If the return value is 0, it means that the two are equal. The ASCII value between them is compared. When Data1<Data2, a negative number is returned, otherwise a positive number is returned. For the implementation of this function, please refer to the introduction in our Baidu Encyclopedia.

http://baike.baidu.com/link?url=doE09oASDZPFpJ5iachmEj2rWNx7DJZ0cAWTUW5-rguGpIphvDL7WL4BM5Tas66zpDCVk6A9WEQnkT39DvZUEK

Well, we have introduced our DMA, it is very convenient for data transmission, especially in image data transmission, because the image data volume is relatively large, it is too time-consuming and laborious to transfer it through the CPU. Of course, DMA is not limited to such an application, there are other applications.

At the same time, we also need to understand that when we use DMA, we do not need the CPU to interfere with data transmission, but we need to understand that there are only so many data buses in the CPU, and DMA will occupy the data bus when transmitting data. Therefore, if the CPU needs to read and write data, it cannot do so at the same time. This is a point we need to make clear. At this time, the CPU can perform corresponding calculations, but data transmission must be coordinated with DMA, because after all, there are only so many data buses.


That’s all for today.


Please click below to download the code Read the original text .

Welcome to watch

[Interesting Talk about MSP430] Lecture 1 of MSP430

[Interesting Talk about MSP430] Lecture 2 of MSP430

[Interesting Talk about MSP430] Lecture 3 of MSP430

[Interesting Talk about MSP430] Lecture 4 of MSP430

[Interesting Talk about MSP430] Lecture 5 of MSP430

[Interesting Talk about MSP430] Lecture 6 of MSP430

[Interesting Talk about MSP430] Lecture 7 of MSP430

[Interesting Talk about MSP430] Lecture 8 of MSP430

[Interesting Talk about MSP430] Lecture 9 of MSP430

[Interesting Talk about MSP430] Lecture 10 of MSP430

[Interesting Talk about MSP430] Lecture 11 of MSP430

[MSP430 Fun Talk] MSP430 Lecture 12: ADC (Part 1)

[Interesting Talk about MSP430] MSP430 Lecture 12: ADC (Part 2)


Recommended recent content:

Miscellaneous talks on rectification (I)

Miscellaneous talks on rectification (Part 2)

Miscellaneous talks on rectification (Part 3)

Miscellaneous talks on rectification (IV)




Latest articles about

 
EEWorld WeChat Subscription

 
EEWorld WeChat Service Number

 
AutoDevelopers

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building,Block B, 18 Zhongguancun Street, Haidian District,Beijing, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号