 Okay, we test the first approach, the UART with the pulling mode, then we test the UART with the interrupt and now we also test the UART with the TMA, then we look on the UART. We again set the F4 for one LQFP64 PIM package, STM32F for one RET, which is on my NUCLO kit. And for the DMA I will use again the UARTU SART1 in the Asynchronous mode on the PIN PA9 and PA10. And I have these pins connected together with my cable, yes I have my PIN PA10, PA9 and PA10 connected together with the cable. Okay, from the pin out, this is everything what I need, only two pins for my UART. On the clock configuration, I am also okay with the 16 MHz, then we move to the main configuration. And we have the UART, we check the parameters, again I am okay with the 115200 POUTS, it's everything perfect. But now I will not change the NVIC, this will be the same, but here I will use the DMA. Then I add the DMA stream, I select what will be the direction, then I will create one for the transmit. I can select the stream, sometimes more streams, and the direction is from memory to PFR, which is okay because this is for the transmit. And during the transmit, I billeted the data from my memory and I put it into the UART, which is the PFR, then the direction is okay. Also the priority now doesn't matter because I have only one, I will have two DMA streams but they will not run in the concurrent way, then it's okay. In here I will select the receive, the stream 2, I can use also stream 5, but I don't want. And the direction is from the PFR to memory, which is okay for the reception. What I need to check, I need to check here if it's here checked the memory increment for both use-hards and the rest can be left unchanged, normal mode, non-cycler mode. It's okay, then I can save here this one, I can change my settings into my examples, I will name it UART3 and I will use the IR. I think it's okay, then I can generate my project, let him to open my project, okay my project is opened, then we can cross check our user section, the main scene. You can see there is something new, when initializing also there is the DMA in it, we first check the UART in it, or UART in it, it's completely the same like before with the interrupts, but we have here the DMA in it, what we have here, we enabling the DMA interrupts, this is necessary to notify us when the DMA ends, but here is missing the DMA initialization because how we configured the DMA, but because the DMA is here the related periphery to the UART, then we have here in the MSP initialization we have the configuration of the pins, but here we have also the DMA initialization, it's again the same structure, we have the DMA handle, we set the instance from this handle and then we fill the initial structure like on the UART, there we set the the direction that we want to increment the memory, that the DASLA size and memory size it's in the bytes and the mode is normal and then we call the DMA HL DMA in it, but something new and here important we need to link together the UART and the DMA, then for this we use the the macro hl underscore underscore hl underscore link DMA, which links together the handle from UART and also the handle from the DMA, then the DMA knows which pathway using this DMA and UART knows which DMA to use, this is this is all from this part, we can also look into the interrupts because we're using the interrupts now also to notify the DMA that DMA ends, again we have here the DMA handler and we're using the HL HL handle, but now where to find the callbacks, because we're using here now the DMA interrupts, we need to search for the DMA callbacks, the answer is no, because the DMA don't have their own callbacks, the DMA is using the callbacks from UART, then in our case when we're searching for callbacks we will not search into the DMA, we will still use the UART callbacks, then here we search for the underscore underscore weak, not MSP in it, not this one, but for example to transmit complete callback I can put it into into my main and also here will be a reception complete callback, then I will use also the reception complete callback, here I put again my while to notify me about the end of this of the reception and you can see because we linked together the DMA and UART, then this is the reason why the DMA can use the UART or UART callbacks, then we don't need to search for the DMA callbacks, we only using the one type of the callbacks and I will also create two buffers, one for the transmission and second for the for the reception, okay the buffers are prepared then I can do the same thing like in the interrupt interupt I start with the hl underscore UART and first I will call the reception but now with the DMA don't forget on the DMA word, I again put the handle name it will be H I think UART UART 1, the second parameter if I'm not sure I will go to the definition into the C, second parameter is the how many how many the pointer on the data and last parameter the third parameter is the size, how many bytes I want to receive then it will be here the buffer buffer for receiving and 10 bytes why not and then I will put the hl UART the transmit with DMA again the DMA must be there the h UART 1 the buffer for transmit and the 10 bytes okay now I can compile my code maybe I forget to change also the optimization why not here in the compiler optimization I set none I will compile it again and I can run my debug okay this is okay I can put here the breakpoint and I can put here these two variables into into the watch here I can show it out to watch they are now here on the right side you can see the reception buffer is empty now the transmission buffer is is full then when I run the code you can see that we receive what we are sending I can make also test when I start again I reset the microcontroller I disconnect my cable and run it again and you see I never received the the bytes I'm still waiting on the interrupt and to receive 10 10 bytes if I connect it again back I get this and I have here the correct correct by number of bytes then this was the the DMA example with the UART it's not so not so more difficult than the interrupt okay we can look on the DMA with the UART with the theoretical point of view we can summarize what we know what is new here is the DMA initialization the UART initialization is the same in the DMA initialization we only enable the DMA and we enable the interrupts from the DMA because the DMA must notify us that the DMA ends okay it's not necessary but otherwise you need to always check the status of the of the periphery then definitely the DMA initialization is in the msp msp in it which is which is now new it was not in the in the previous previous initialization it's below usually the pin initialization but the important is the link between the DMA and the and the UART when if we remember the the UART handle we have there the pointers to the DMA which can point which DMA is used together with this with this periphery and in the DMA handle it's also the parent pointer which will point back to our our UART this is only showing how it looks like the the DMA link DMA function which connects together the UART UART handle or the different handle and also the handlers from the from the from the DMA but this all is done automatically in inside the cube Mx here only showing showing how this looks like then the UART handle have pointer to the DMA handlers and the DMA handlers have also pointers on the UART then the DMA knows which payfair it's using the DMA and the UART know which DMA he needs to use yes then this is this is the still the same in the interrupt we have the interrupt handler we're using the the HL DMA DMA interrupt handler which for us clear the flags check how many bytes we receive but the callbacks will be always the same then we're using the the UART callbacks we can also use now the half transfer callback that mean we are in the in the half of our buffer in our case when we receive or transmit 10 bytes then the half transfer is the five and how it looks like like the interrupt the DMA is not blocking function this mean that we call the reception if everything is okay we end with the with the okay or we end with the error and then when we receive the byte then we go into the interrupt I think the automatically many of bytes we give in the interrupt handler in the HL interrupt handle we check if we have the DMA error if yes we error we end up in the UART error callback if not we go we check if we have in the half transfer interrupt if yes we call the half transfer interrupt if not we check the transfer complete interrupt if yes we go into the half transfer in the transfer complete callback and we end the interrupt then the again the UART with the DMA is completely not blocking what is the difference between the interrupt interrupt in the interrupt version we get the interrupt each byte which we received in the DMA we get the interrupt only in the half transfer or in the half transfer complete this mean that this more offloads the CPU this is reason why to use the DMA