5.5.8 · D3 · HinglishEmbedded Systems & Real-Time Software

Worked examplesDMA — memory-to-memory, peripheral-to-memory without CPU

3,691 words17 min read↑ Read in English

5.5.8 · D3 · Coding › Embedded Systems & Real-Time Software › DMA — memory-to-memory, peripheral-to-memory without CPU

Yeh page DMA ka exhaustive drill room hai. Parent note ne formulas banaye; yahan hum unhe har kone mein push karte hain — har transfer direction, tricky zero aur degenerate inputs, limiting cases, ek real-world word problem, aur ek exam-style twist jo ek trap chupaata hai.

Sab kuch parent ke do formulas par tika hai. Chaliye unhe phir se state karte hain taaki koi symbol unexplained na rahe:


Scenario matrix

Har DMA question jo tumhare saamne aayega, in cells mein se kisi ek mein fit hoga. Neeche ke examples [CELL n] label kiye gaye hain taaki tum dekh sako ki poora space cover hua hai. (Yaad karo upar se: bytes mein per-beat source/destination address steps hain; = forward, = fixed, = backward.)

Cell Case class Kya special hai Covered by
1 Mem-to-mem, dono addresses increment Ex. 1
2 Periph-to-mem, source fixed Ex. 2
3 Mem-to-periph, dest fixed Ex. 3
4 Address decrement mode (backward walk) Ex. 4
5 Degenerate: kuch move nahi hota — kya time = 0? Ex. 5
6 Degenerate: wait states slow peripheral har beat inflate karta hai Ex. 6
7 Limiting case: width sweep throughput jab Ex. 7
8 Real-world word problem audio streaming, must-not-miss deadline Ex. 8
9 Exam twist mixed units + "started ≠ done" trap Ex. 9

Examples

[CELL 1] Mem-to-mem — dono addresses forward chalte hain

Isse memcpy and Block Copy software mein karne se compare karo — CPU yahan ~4 cycles/word burn karega instead of pipeline free karne ke.


[CELL 2] Periph-to-mem — source address frozen rehti hai


[CELL 3] Mem-to-periph — destination address frozen hai

Continuous audio ke liye tum isse Circular and Double Buffering ke saath loop karoge taaki buffer refill hota rahe jab DMA doosra half drain kare.


[CELL 4] Address-decrement mode — backward chalna


[CELL 5] Degenerate input —


[CELL 6] Degenerate timing — wait states har beat inflate karte hain


[CELL 7] Limiting case — item width sweep karo


[CELL 8] Real-world word problem — audio deadline


[CELL 9] Exam twist — mixed units + "started ≠ done" trap


Scenario coverage check

Recall Kya humne har cell hit kiya?

Mem-to-mem (Ex.1) ::: ✓ dono deltas = +w Periph-to-mem (Ex.2) ::: ✓ source fixed (0), dest +w Mem-to-periph (Ex.3) ::: ✓ source +w, dest fixed (0) Decrement mode (Ex.4) ::: ✓ , timing unchanged degenerate (Ex.5) ::: ✓ t=0 lekin setup (four SCAM regs) ≠ 0 Wait states (Ex.6) ::: ✓ t aur throughput mein 5× penalty Width sweep limit (Ex.7) ::: ✓ , capped by bus width / alignment Real-world deadline (Ex.8) ::: ✓ ~1500× margin, audio deadline meet hoti hai Exam twist (Ex.9) ::: ✓ async + cache coherency traps