DMA is configured in half mode, how do I configure it in full mode?
Hello,
I'm learning DMA and using CubeMX to generate the configuration codes and SystemWorkbench(Eclipse) as editor to edit my application.
To better grasp the concept of DMA I'm doing a small project in which I use USART in combination with DMA to read some data from the PC's terminal and reply from the code according to 3 situations. Here is how the project is supposed to work:
1) I send some data from the PC via Terra Term and ask a question:
For this I have configured DMA1 Stream 5 as Peripheral to Memory and USART2_RX as DMA
request.
2) According to what text I receive I send some data back via the USART to the PC and print
some stuff on the terminal.
For this I have configured DMA1 Stream 6 as Memory to Peripheral and USART2_TX serves as DMA request.
The problem I encountered is at step 1:
In my application code I have defined a function: 'cmplt_DMA_Receive' which I intended to use as complete DMA receive callback in my application where I would write my logic.
So I did this:
hdma_usart2_rx.XferCpltCallback = &cmplt_DMA_Receive;And was expecting to have this function called when I send a character on the terminal(I have configured the DMA to send byte by byte so the function should be called after each received byte - character).
However the function was not getting called after doing some debugging I have found out that, in the HAL_DMA_IRQHandler global interrupt, the weak unimplemented callback function for half transfer complete(XferHalfCpltCallback) gets called instead of the callback XferCpltCallback for full DMA transfer complete which I implemented in the main.c file.
Apparently the stream used in step 1 is configured in half mode and not in full mode as I was expecting it to be by default. Previously I did a memory to memory exercise and that callback was getting called as I was expecting.
Now apparently the CubeMx configured the DMA stream as half transfer and I don't know how to change it to full transfer so I can have that callback in the application be called.
Please help me correct this by helping me configure it from the CubeMX software - I do understand what the difference between a full and half DMA transfer is from the datasheet however I do not know where to make that configuration in CubeMX software.
Thank you very much for reading this! I will reply with the full code as the text would be too long if I did it in the same post.