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!

BackToBasics: Bleeder Resistors

This is one of the simplest design choices you can make in a power supply, yet I rarely see folks implementing them in their projects. Today, let’s dive into the world of bleeder resistors, their importance, and how to choose the right one for your circuits.

A bleeder resistor is a resistor connected across the terminals of a capacitor or in the output of a power supply. Its function is to safely discharge the stored energy in the capacitor when the power supply is turned off. This ensures that there is no residual voltage left in the capacitor.

Why use a bleeder resistor? First, it’s about safety. Personally, I have experienced multiple “discharge shocks” when repairing boards with large capacitors. They pack a punch and it hurts. Hence for large capacitors, using bleeder resistors is mandatory. Second, it allows components to turn off completely. When a large capacitor holds charge, the rest of the circuit remains charged and isn’t effectively off when power is removed. This causes a delay before a proper reset. If you plug the power back in, your digital circuits might not have had the chance to turn off before power is reapplied. Hence, they tell you to turn OFF power and wait for X seconds before turning it ON again.

How to select one? My rule is to use a resistor that is not too low(because idle power loss will be higher) and not too high(Discharge time is longer). Firstly, figure out how fast you want to discharge the caps after powering them off. That value equals 5 times the RC time constant(5 is just to get the value to zero, Realistically you don’t need to unless you are in the high voltage domain. Check the table to figure out your sweet spot). Now you have your resistor value, this resistor needs to be power-rated using V^2/R based on the voltage held initially by your cap.

The design is that simple. So please next time use them in your design. It doesn’t cost much. Even a slow discharge circuitry is better than no discharge one.

If you liked the post, Share it with your friends!
1 30 31 32 33 34 99