I'm trying to understand DMA usage by testing a simple application. The idea is to allow USART peripheral to access read and write from and to memory directly, by using DMA technique. I'm testing this on STM32F0 Discovery board. After reading some generic literature on DMA and reference manual of this particular SOC (STM32F051XX), my understanding on DMA capable, USART operation for data reception (i.e. Data transfer direction is from Peripheral to Memory) is as follows:
- Data arrives from external world (Say through USB Serial COM port on PC to GPIO pins on USART port. I'm using RealTerm on Windows to send and receive data). Peripheral sends, request signal to DMA controller. This leads to Interrupt request (DMA_IRQ) generation.(H/W)
- DMA controller Ack's the requesting Peripheral. (H/W)
- ISR associated with the DMA_IRQ gets invoked. Polling for 'transfer complete flag' starts.(S/W)
- Bus Matrix, ask Cortex Core to relinquish the System Bus. Assuming a simple scenario here, where there are only two bus consumers; Core CPU and DMA Controller. (H/W)
- Core relinquishes the System bus, Bus Matrix allows DMA controller to access the system bus. (H/W)
- DMA controller access the Peripheral register. Based on DMA and Peripheral (In this case, USART1) configuration, data is transferred from and to memory(If both Tx and Rx directions were configured). (H/W)
- This data transfer can happen over multiple separate channels (To achieve parallelism and to avoid contention, I guess). (H/W)
- Once the data transfer (As configured during the DMA setup, such as data size, memory location, direction etc) is complete, DMA controller relinquish the bus. (H/W)
- Bus Matrix grants, System bus access to CPU (Considering the simplest case. (H/W)
- DMA controller sets 'Transfer complete flag' for Systems programming purposes(H/W)
- In the ISR, this transfer complete flag is checked and once set, necessary action is taken and before leaving ISR, 'transfer complete flag' is reset.(S/W)
H/W = Handled by Hardware
S/W = Handled by Software
Based on above understanding and some sample code DMA related code distributed by STM and in this forum, Below is my simple application. The idea is to transfer some characters over USART1 interface, transfer this data into memory using DMA and toggle the LED on evaluation board to indicate the completion of transfer.
Below is the code snip:
Compilation happens fine, but it seems that the DMA1_Channel2_3_IRQHandler is not getting invoked and hence I do not see the LED getting Toggled :(
Also attach here is the Screenshot of RealTerm Settings (1) and the send tab in RealTerm, where I try to send a character (2).
Thank you for your help.