0
0
Embedded Cprogramming~10 mins

Circular buffer DMA mode in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the size of the circular buffer.

Embedded C
volatile uint8_t dma_buffer[[1]];
Drag options to blanks, or click blank then click option'
A256
B512
C1024
D128
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a size that is not a power of two.
Using a size too large for the memory.
2fill in blank
medium

Complete the code to enable circular mode in the DMA configuration.

Embedded C
DMA_InitStructure.DMA_Mode = [1];
Drag options to blanks, or click blank then click option'
ADMA_Mode_MemoryToMemory
BDMA_Mode_PeripheralControl
CDMA_Mode_Normal
DDMA_Mode_Circular
Attempts:
3 left
💡 Hint
Common Mistakes
Using normal mode which stops after one transfer.
Choosing memory-to-memory mode which is not suitable here.
3fill in blank
hard

Fix the error in the DMA interrupt flag clearing code.

Embedded C
DMA_ClearFlag(DMA1_Stream5, [1]);
Drag options to blanks, or click blank then click option'
ADMA_FLAG_FEIF5
BDMA_FLAG_TEIF5
CDMA_FLAG_TCIF5
DDMA_FLAG_HTIF5
Attempts:
3 left
💡 Hint
Common Mistakes
Clearing the half-transfer flag instead of transfer complete.
Clearing error flags which do not acknowledge normal completion.
4fill in blank
hard

Fill both blanks to correctly configure the DMA buffer size and enable the DMA stream.

Embedded C
DMA_InitStructure.DMA_BufferSize = [1];
DMA_Cmd(DMA1_Stream5, [2]);
Drag options to blanks, or click blank then click option'
A256
BENABLE
CDISABLE
D128
Attempts:
3 left
💡 Hint
Common Mistakes
Using a buffer size that does not match the array.
Disabling the DMA stream by mistake.
5fill in blank
hard

Fill all three blanks to correctly set the DMA peripheral address, memory address, and data direction.

Embedded C
DMA_InitStructure.DMA_PeripheralBaseAddr = [1];
DMA_InitStructure.DMA_Memory0BaseAddr = [2];
DMA_InitStructure.DMA_DIR = [3];
Drag options to blanks, or click blank then click option'
A(uint32_t)&USART1->DR
B(uint32_t)dma_buffer
CDMA_DIR_PeripheralToMemory
DDMA_DIR_MemoryToPeripheral
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping peripheral and memory addresses.
Setting direction incorrectly as memory to peripheral.