STM32 LESSON #7: UART (INTERRUPT + DMA)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys we are going to add interrupt for uart communication open your previous project and enable the uart global interrupt and generate the [Music] project open main.c and comment receiver function and edit transmit function in the first step we only test the transfer function the interrupt does not require a timeout value now we need to add the TX callback function so that it can set the flag we need to look at the how library to find the function copy and paste it into your main. C add the condition to check to which usart this interrupt belongs [Music] I Define a variable as [Music] counter and I put it in the Callback function as you can see in the debug txcn is increment by one after sending a text now I want to add the receive function if you remember from the previous lesson receive to idle was better than normal receive performance because we usually don't know how many bytes are received in a packet add call back function like [Music] TX compile and program and watch the result in debug [Music] this callback function only works once you need to add it again in the Callback to get more packets [Music] now it works well in interrupt mode when a bite is received by Art the CPU jumps to a callback function where it stores the received data into a variable and increments the counter however in dma mode all of these tasks are handled without involving the CPU allowing it to focus on other tasks open Cub MX and go to the dma settings [Music] tab press add and select RX in RX DM the direction should be from peripheral to memory as it involves receiving data from the peripheral and Stor ing it directly into memory for the data width it should be set to bite additionally select increment address for memory meaning that after receiving a bite the memory address should increase and we select normal mode for this example press add and select [Music] TX for TX choose memory to peripheral because we're sending data from memory to the peripheral and keep other settings like RX generate project and open main. C convert all function endings with it to [Music] dma compile and open [Music] debug that is it by converting the functions to dma you maintain similar functionality to interrupt mode but with reduced CPU load Please Subscribe my channel and hit the like button thank you
Info
Channel: NimaLTD
Views: 432
Rating: undefined out of 5
Keywords: C library, stm32, stm32 library, learning, embedded, uart, usart, dma, interrupt, lesson, hal
Id: MIHZONSF-Gc
Channel Id: undefined
Length: 4min 45sec (285 seconds)
Published: Sat Mar 02 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.