0
0
Embedded Cprogramming~10 mins

Peripheral-to-memory transfer 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 start the peripheral-to-memory DMA transfer.

Embedded C
DMA_Start_Transfer([1]);
Drag options to blanks, or click blank then click option'
ADMA_CHANNEL_1
BTIMER2
CADC1
DUART1
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the peripheral name instead of the DMA channel.
Using a timer channel instead of DMA channel.
2fill in blank
medium

Complete the code to configure the DMA data size for peripheral-to-memory transfer.

Embedded C
DMA_Config.DataSize = [1];
Drag options to blanks, or click blank then click option'
ADMA_DATA_SIZE_64BIT
BDMA_DATA_SIZE_8BIT
CDMA_DATA_SIZE_32BIT
DDMA_DATA_SIZE_16BIT
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 8-bit size when peripheral sends 16-bit data.
Selecting unsupported 64-bit size.
3fill in blank
hard

Fix the error in the DMA transfer complete interrupt handler to clear the interrupt flag.

Embedded C
void DMA_IRQHandler(void) {
    if (DMA_GetFlagStatus([1])) {
        DMA_ClearFlag([1]);
        // Process data
    }
}
Drag options to blanks, or click blank then click option'
ADMA_FLAG_TE1
BDMA_FLAG_HT1
CDMA_FLAG_TC1
DDMA_FLAG_GL1
Attempts:
3 left
💡 Hint
Common Mistakes
Clearing half-transfer flag instead of transfer complete.
Not clearing any flag causing interrupt to repeat.
4fill in blank
hard

Fill both blanks to set the peripheral and memory addresses for DMA transfer.

Embedded C
DMA_Config.PeripheralBaseAddr = [1];
DMA_Config.MemoryBaseAddr = [2];
Drag options to blanks, or click blank then click option'
A(uint32_t)&UART1->DR
B(uint32_t)&ADC1->DR
C(uint32_t)buffer
D(uint32_t)data_array
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping peripheral and memory addresses.
Using ADC1 address when UART1 is the peripheral.
5fill in blank
hard

Fill all three blanks to configure DMA transfer direction, enable circular mode, and set priority.

Embedded C
DMA_Config.Direction = [1];
DMA_Config.Mode = [2];
DMA_Config.Priority = [3];
Drag options to blanks, or click blank then click option'
ADMA_DIR_PeripheralSRC
BDMA_DIR_PeripheralDST
CDMA_MODE_Circular
DDMA_PRIORITY_High
Attempts:
3 left
💡 Hint
Common Mistakes
Setting direction as peripheral destination.
Using normal mode instead of circular for continuous transfer.
Setting low priority causing delays.