{"id":1233,"date":"2022-10-02T05:24:48","date_gmt":"2022-10-02T05:24:48","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=1233"},"modified":"2022-10-02T05:24:51","modified_gmt":"2022-10-02T05:24:51","slug":"working-with-stm32f7-and-uart-part-3-transmitting-data-using-dma","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=1233","title":{"rendered":"Working with STM32F7 and UART part 3: Transmitting Data using DMA"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"441\" height=\"259\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/08\/UART-BUS-between-two-devices.jpg\" alt=\"\" class=\"wp-image-330\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/08\/UART-BUS-between-two-devices.jpg 441w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/08\/UART-BUS-between-two-devices-300x176.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/08\/UART-BUS-between-two-devices-400x235.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/08\/UART-BUS-between-two-devices-250x147.jpg 250w\" sizes=\"(max-width: 441px) 100vw, 441px\" \/><\/figure><\/div>\n\n\n\n<p>In the previous guide (<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.embeddedexpert.io\/?p=667\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=667\" target=\"_blank\">here<\/a>), we saw how to configure the uart to receive single character. In this guide, we shall use DMA to transmit data over UART.<\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>UART Configuration for DMA in TX Mode.<\/li><li>DMA Configuration.<\/li><li>UART TX in DMA mode function<\/li><li>Code.<\/li><li>Results<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. UART Configuration for DMA in TX Mode:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>We start from part one (<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.embeddedexpert.io\/?p=640\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=640\" target=\"_blank\">here<\/a>), Now, we need to enable DMATX for the USART3. In order to enable it, we need to set bit DMAT in CR3:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-1024x370.png\" alt=\"\" class=\"wp-image-1234\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-1024x370.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-300x108.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-768x277.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-1536x554.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-2048x739.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-1150x415.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-750x271.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-400x144.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.04.22-AM-250x90.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">USART3-&gt;CR3|=USART_CR3_DMAT;<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. DMA Configuration:<\/h2>\n\n\n\n<p>In order to check with DMA, Stream and channel needed for the USART, we need to check the DMA request mapping within the reference manual of STM32F767.<\/p>\n\n\n\n<p>We can see that DMA1 Stream3 Channel4 is responsible for USART3_TX, hence we shall use DMA1_Stream3 channel 4 in this guide.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"496\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-1024x496.png\" alt=\"\" class=\"wp-image-1235\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-1024x496.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-300x145.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-768x372.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-1536x744.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-1150x557.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-750x363.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-400x194.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM-250x121.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.10.18-AM.png 1916w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>We start configuring the DMA1 as following:<\/p>\n\n\n\n<p>Enable clock access to DMA1:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">RCC-&gt;AHB1ENR|=RCC_AHB1ENR_DMA1EN;<\/pre><\/div>\n\n\n\n<p>Make disable the stream and make sure it is disabled:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\tDMA1_Stream3-&gt;CR &amp;=~(DMA_SxCR_EN);\n\twhile((DMA1_Stream3-&gt;CR &amp;(DMA_SxCR_EN)));<\/pre><\/div>\n\n\n\n<p>Configure the DMA as following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Channel 4.<\/li><li>Memory to Peripheral.<\/li><li>Memory increment mode.<\/li><li>Transfer complete interrupt.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"383\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-1024x383.png\" alt=\"\" class=\"wp-image-1236\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-1024x383.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-300x112.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-768x288.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-1536x575.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-2048x767.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-1150x431.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-750x281.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-400x150.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.14.22-AM-250x94.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#define ch4 0x04\nDMA1_Stream3-&gt;CR|=(ch4&lt;&lt;25)|DMA_SxCR_MINC|DMA_SxCR_DIR_0|DMA_SxCR_TCIE;<\/pre><\/div>\n\n\n\n<p>Set the peripheral address to TDR register of USART3 as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">DMA1_Stream3-&gt;PAR=(uint32_t)&amp;USART3-&gt;TDR;<\/pre><\/div>\n\n\n\n<p>Enable the interrupt in NVIC controller:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">NVIC_EnableIRQ(DMA1_Stream3_IRQn);<\/pre><\/div>\n\n\n\n<p>for the interrupt handler:<\/p>\n\n\n\n<p>We check if the source is transfer complete interrupt from channel3 and set tx_finished to 1 then clear the pending interrupt.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\nvoid DMA1_Stream3_IRQHandler(void)\n\t{\n\t\tif(DMA1-&gt;LISR &amp; DMA_LISR_TCIF3)\n\t\t\t{\n\t\t\t\ttx_finished=1;\n\t\t\t\tDMA1-&gt;LIFCR=DMA_LIFCR_CTCIF3;\n\t\t\t}\n\n\t}\n<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. UART TX in DMA Mode:<\/h2>\n\n\n\n<p>We start of by declaring a function thats will take two arguments:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Pointer to the data that hold the data to be transmitted.<\/li><li>Length of the data to be transmitted.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void usart_dma_write(char *data, uint16_t length)<\/pre><\/div>\n\n\n\n<p>Within the function, we shall set the memory of DMA1 to the data buffer:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">DMA1_Stream3-&gt;M0AR= data;<\/pre><\/div>\n\n\n\n<p>The length to be the length passed to the function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">DMA1_Stream3-&gt;NDTR=length;<\/pre><\/div>\n\n\n\n<p>Start the stream:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">DMA1_Stream3-&gt;CR|=DMA_SxCR_EN;<\/pre><\/div>\n\n\n\n<p>Wait until the transfer is completed (depending on your application):<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">while(tx_finished==0);\ntx_finished=0;<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Code:<\/h2>\n\n\n\n<p>In main.c file, we shall use counter to be displayed:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;uart.h&quot;\n#include &quot;stm32f7xx.h&quot;\n\n\nchar uart_data_tx[40];\nuint8_t counter=0;\nuint8_t length;\nvoid delay(int ms)\n{\n\tint i;\n\tSysTick-&gt;LOAD=16000-1;\n\tSysTick-&gt;VAL=0;\n\tSysTick-&gt;CTRL=0x5;\n\t\tfor ( i=0;i&lt;ms;i++)\n\t\t{\n\t\t\twhile(!(SysTick-&gt;CTRL &amp;0x10000)){}\n\t\t}\n\tSysTick-&gt;CTRL=0;\n\n}\n\n\n\n\nint main(void)\n\t{\n\t\tuart_tx_dma_init();\n\t\twhile(1)\n\t\t\t{\n\t\t\t\tlength=sprintf(uart_data_tx,&quot;Counter value = %d\\r\\n&quot;,counter++);\n\t\t\t\tusart_dma_write(uart_data_tx,length);\n\t\t\t\tdelay(200);\n\t\t\t}\n\n\n\t}\n<\/pre><\/div>\n\n\n\n<p>You may download the code from here:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/UART_TX_DMA.zip\">UART_TX_DMA<\/a><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/UART_TX_DMA.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Results:<\/h2>\n\n\n\n<p>After you compile and upload the code to your Nucleo-144 F767, open serial terminal and set the baudrate to be 115200 and you will see this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"724\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-1024x724.png\" alt=\"\" class=\"wp-image-1238\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-1024x724.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-300x212.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-768x543.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-1150x814.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-750x531.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-400x283.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM-250x177.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-02-at-8.24.08-AM.png 1176w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous guide (here), we saw how to configure the uart to receive single character. In this guide, we shall use DMA to transmit data over UART. In this guide, we shall cover the following: UART Configuration for DMA in TX Mode. DMA Configuration. UART TX in DMA mode function Code. Results 1. UART [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-1233","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1233"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1233"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1233\/revisions"}],"predecessor-version":[{"id":1239,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1233\/revisions\/1239"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}