Join our subscribers list to get the latest news, updates and special offers directly in your inbox
Overview
CPU is an essential part of an Embedded System that manages all the arithmetic, logic, control, and I/O operations. The main components of the CPU are Control Unit (CU), Arithmetic & Logic Unit (ALU), and the registers.
CU manages the ALU and memory communication for executing or storing the instructions. It includes the fetching unit for fetching the instructions. On the other hand, the ALU unit manages all the arithmetic and logical operations. During the data transmission between memory and the peripherals, a delay will add if the CPU is engaged to accomplish some other task. Therefore, the system performance gets degraded.
As shown above, the CPU and multiple peripherals connect with a bus matrix. The in-hardware CPU uses the bus interconnected (further expands to the data, control and address bus) to load the data from one of the peripherals and then store it in memory or vice-versa. As a Use Case scenario, the UART is one of the peripherals and wants to transfer the data from its data register to the memory. Therefore, the CPU needs to be programmed to do this transfer of data from the UART Data Register to the memory.
DMA, or Direct Memory Access, is a vital mechanism in Embedded systems designed to address the inefficiencies associated with data transfer between peripheral devices and memory. Traditionally, the CPU has been responsible for managing these transfers, creating a bottleneck that hampers overall system performance.
Embedded systems often contend with limited resources, and the conventional method of relying on the CPU for every data transfer proves to be inefficient. DMA addresses this challenge by allowing peripheral devices, such as sensors or communication modules, direct access to the system's memory. This alleviates the CPU from continuous involvement in data transfers, optimizing resources and reducing processing overhead.
The peripherals can only generate the asynchronous events (interrupts) to indicate to the CPU that data is ready but unable to do the bus transactions. Therefore to offload the CPU, a kind of master is essential who can do these transactions without the CPU intervention. The Hardware IP that can control the data transfer between the memory and the peripherals without the CPU involvement is known Direct Memory Access (DMA) controller. DMA can access the memory and the peripherals directly for doing the bus transactions. However, Load Store instruction execution and other internal circuitry would only be active during the CPU execution. Therefore, Power Consumption will be less with DMA because the CPU can be in sleep mode during the data transmission.
A System on Chip (SoC) is an integrated circuit with all the essential elements required for an Embedded System. In an SoC, the Advanced Microcontroller Bus Architecture (AMBA) is an open standard that is developed by ARM. AMBA has a master-slave type of topology, only the master can initiate the communication. AMBA connects and manages all the components like Memory and Peripherals e.g. UART, CPU and etc. For managing on-chip communication AMBA has three buses as follows, Advanced High-Performance Bus (AHB), the Advanced System Bus (ASB), and the Advanced Peripheral Bus (APB). The AHB facilitates high-frequency and high-performance components. On the other hand, ASB is an alternative to the AHB but with limited features. Whereas, APB is for taking care of the low bandwidth peripherals like GPIOs, Timers, and UART.
The master has the privilege to control the bus and there can be multiple masters in an SoC, but a single master would be able to access the bus at a particular time. To resolve the multi-master access request in hardware, an arbiter is used. When any master wants to control the AHB bus, it sends a request signal to the arbiter and it will provide access if the bus is available at that particular time. If multiple masters send an access request signal simultaneously, then access will be given to the master having higher priority. Therefore, another master request can stop the CPU access to the system bus for a few bus cycles when the CPU and another master are trying to access the same destination simultaneously.
The bus matrix provides access from a master to a slave, enabling concurrent access and efficient operation. The description of these masters is as below:
Let's take an example of ARM Cortex M-4 architecture, where the system consists of a 32-BIT multilayer AHB bus matrix that interconnects multiple masters and slaves. CPU Instruction, Data, System bus, DMAs, and USB are acting as masters. On the other hand, Flash, SRAM, and all the peripherals connected with AHB & APB buses are working as a slave.
DMA controller supports two transfer modes which are as below:
DMA can be configured into 3 Modes:
Let's consider one application where a SPI based temperature sensor is connected to the microcontroller and firmware inside CPU wants to read the data from the sensor. To do the same transfer using DMA without the intervention from CPU so that data can be stored into the memory without any delay, as CPU may be busy in performing another high priority task. Communication steps would be as below:
In the end, we can conclude that Fast Data transfer between Memory and Peripherals is possible using DMA. CPU and DMA can also operate concurrently which provides better performance. It also helps in reducing power consumption if the CPU is in sleep mode.
EmbeddedWala
EmbeddedWala Jun 14, 2023 0 21.5K
EmbeddedWala Apr 27, 2023 0 20.9K
EmbeddedWala Apr 26, 2023 0 18.4K
EmbeddedWala Aug 30, 2022 0 16.4K
EmbeddedWala Apr 27, 2023 0 16.4K
EmbeddedWala Jun 19, 2022 0 4.8K
This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies Find out more here