Back To Basics: DMA

Direct Memory Access (DMA) is a feature in embedded systems that folks often overlook. In a typical microcontroller, the CPU is responsible for transferring data between peripherals and memory. This means the CPU has to read data from a peripheral, process it, and then write it to memory. This process is not only time-consuming but also keeps the CPU busy, preventing it from performing other tasks.


Enter DMA controller. Think of these as a separate co-processor with limited capabilities in your uC. Technically it’s a state machine that can do at least 3 things, Wait for a control input, read from a place, and write to another place. It acts on its own with involvement from CPU freeing it to do other tasks. This is crucial in real-time systems where the CPU needs to perform critical tasks without interruption. By offloading data transfer tasks, DMA can handle large amounts of data quickly and efficiently. Think, continuous input streams from an external accelerometer or an audio stream. CPU kicks in only when the data transfer is complete to process the data, it doesn’t have to concern itself with the transfer. Another key advantage is since the CPU can remain in a low-power state during DMA operations, overall power consumption is reduced. This is vital in battery-powered devices.

Different manufacturers implement DMA in uCs in various ways. Usually you DMA channels, with each channel assigned for a particular task like one for reading from an ADC, one for writing to a USB bus etc. Each can have its own priority of execution. There can even be multiple DMA reading and writing to separate memory regions. It comes in all flavours. One beautiful implementation of DMA is driving RGB WS28 series LEDs in the Neopixel library. You can read more about them in the Adafruit blogs.

So if you haven’t used DMAs before, do give it a shot next time you need a large data transfer. You can effectively utilize DMA to enhance the performance of your embedded solution.

If you liked the post, Share it with your friends!

Tech Explained: Metal in Microwaves

In Indian kitchens, there has always been a defacto rule that you should never put metal in microwaves. I have always been told that. I never really questioned it till a few years back when I bought one personally. Let’s debunk this.

First, understand how a microwave oven works. Microwaves are electromagnetic waves, similar to light but with a different wavelength. Home ovens typically use a frequency of 2.45GHz (wavelength = 12.25cm), which falls in the free spectrum of usage (like Bluetooth). This microwave is generated by a unit called a magnetron, usually located behind the control panel in the oven. The generated microwaves form a standing wave in the oven’s cavity. A standing wave means the wave appears stationary, with its crests and troughs of the sine wave fixed in 3D space. These waves interact with water molecules in food, rotating them back and forth to generate heat via “friction” and heat up your food.


So, what happens when you put metal in the microwave? Metals reflect nearly 100% of electromagnetic waves, but they also interact with free electrons on the metal’s surface as it can’t penetrate it. If the metal object has sharp, thin edges, electrons can align and build up a large charge at these tips. When this charge exceeds a threshold, it creates a spark. If the metal is very thin, like aluminum foil, this spark can raise the temperature and cause it to catch fire if there is a flammable object like parchment paper.

That’s why you shouldn’t put thin, sharp metallic objects in the microwave. However, if the metal doesn’t have those features, it’s usually fine. Heck, the internal cavity of a microwave is fully made of metal. My rule of thumb is to avoid metal in microwaves whenever possible. If you must use it, ensure there are no sharp edges. But remember metal does get very hot inside the microwave. Please be mindful of that.

BTW it’s perfectly safe to cook food in a microwave, there are absolutely no negative effects on food because it’s cooked in a microwave. Don’t believe those myths.

If you liked the post, Share it with your friends!
1 20 21 22 23 24 86