<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Transmiting a buffer on UART with DMA in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1382668#M62003</link>
    <description>&lt;P&gt;Right now I transmit a buffer by blocking method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;send_log_data_uart0(log_buffer_data, page_chunk);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have to send it using DMA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void DMA_Init(void)
{
	//enable clock for DMAMUX and DMA
	SIM_SCGC6 |= SIM_SCGC6_DMAMUX0_MASK;
	SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;

	//enable channel 0 and set the source - 3 = UART0 Transmit ($3.3.9.1 Table 3-26)
	DMAMUX0_CHCFG0 |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(3);

	//set memory address for source and destination
	DMA_TCD0_SADDR = (uint32_t)&amp;amp;log_buffer_data;  //global scope buffer
	DMA_TCD0_DADDR = (uint32_t)&amp;amp;UART0_D;

    //set an offset
	DMA_TCD0_SOFF = 0;  //???
	DMA_TCD0_DOFF = 0;  //???

	//set data transfer size - byte
	DMA_TCD0_ATTR = DMA_ATTR_SSIZE(0) | DMA_ATTR_DSIZE(0);  //???

	//number of bytes to be transfered in each service request
	DMA_TCD0_NBYTES_MLNO = glob_data_chank;  //???

	//current major iteration count (a single iteration)
	DMA_TCD0_CITER_ELINKNO = DMA_CITER_ELINKNO_CITER(1);  //???
	DMA_TCD0_BITER_ELINKNO = DMA_BITER_ELINKNO_BITER(1);  //???

	DMA_TCD0_SLAST = 0;   //???
	DMA_TCD0_DLASTSGA = 0; //???

	//setup control and status register
	//DMA_TCD0_CSR = 0;

	//interrupt when tx/rx buffer is full. stop DMA on single transfer.
	DMA_TCD0_CSR = DMA_CSR_INTMAJOR_MASK | DMA_CSR_DREQ_MASK;
	//enable request signal for channel 0
	DMA_ERQ = DMA_ERQ_ERQ0_MASK;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have some questions.&lt;/P&gt;&lt;P&gt;1. Those registers with a question sign (//???) - is it configured OK?&lt;/P&gt;&lt;P&gt;2. buffer size can be changed (glob_data_chank). Should I update the DMA_TCD0_NBYTES_MLNO on every service request?&lt;/P&gt;&lt;P&gt;3. How do I set a DMA interrupt? Do I need the interrupt? I can poll the done flag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;while (DMA_TCD0_CSR &amp;amp; DMA_CSR_DONE_MASK)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Do I need any additional setup on UART side? Do I need these lines?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;UART0_C2 |= UART_C2_TIE_MASK;
UART0_C5 |= UART_C5_TDMAS_MASK;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5. How do I start a new transaction? Like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DMA_TCD0_CSR |= DMA_CSR_START_MASK;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 13:35:36 GMT</pubDate>
    <dc:creator>john71</dc:creator>
    <dc:date>2021-12-07T13:35:36Z</dc:date>
    <item>
      <title>Transmiting a buffer on UART with DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1382668#M62003</link>
      <description>&lt;P&gt;Right now I transmit a buffer by blocking method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;send_log_data_uart0(log_buffer_data, page_chunk);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have to send it using DMA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void DMA_Init(void)
{
	//enable clock for DMAMUX and DMA
	SIM_SCGC6 |= SIM_SCGC6_DMAMUX0_MASK;
	SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;

	//enable channel 0 and set the source - 3 = UART0 Transmit ($3.3.9.1 Table 3-26)
	DMAMUX0_CHCFG0 |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(3);

	//set memory address for source and destination
	DMA_TCD0_SADDR = (uint32_t)&amp;amp;log_buffer_data;  //global scope buffer
	DMA_TCD0_DADDR = (uint32_t)&amp;amp;UART0_D;

    //set an offset
	DMA_TCD0_SOFF = 0;  //???
	DMA_TCD0_DOFF = 0;  //???

	//set data transfer size - byte
	DMA_TCD0_ATTR = DMA_ATTR_SSIZE(0) | DMA_ATTR_DSIZE(0);  //???

	//number of bytes to be transfered in each service request
	DMA_TCD0_NBYTES_MLNO = glob_data_chank;  //???

	//current major iteration count (a single iteration)
	DMA_TCD0_CITER_ELINKNO = DMA_CITER_ELINKNO_CITER(1);  //???
	DMA_TCD0_BITER_ELINKNO = DMA_BITER_ELINKNO_BITER(1);  //???

	DMA_TCD0_SLAST = 0;   //???
	DMA_TCD0_DLASTSGA = 0; //???

	//setup control and status register
	//DMA_TCD0_CSR = 0;

	//interrupt when tx/rx buffer is full. stop DMA on single transfer.
	DMA_TCD0_CSR = DMA_CSR_INTMAJOR_MASK | DMA_CSR_DREQ_MASK;
	//enable request signal for channel 0
	DMA_ERQ = DMA_ERQ_ERQ0_MASK;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have some questions.&lt;/P&gt;&lt;P&gt;1. Those registers with a question sign (//???) - is it configured OK?&lt;/P&gt;&lt;P&gt;2. buffer size can be changed (glob_data_chank). Should I update the DMA_TCD0_NBYTES_MLNO on every service request?&lt;/P&gt;&lt;P&gt;3. How do I set a DMA interrupt? Do I need the interrupt? I can poll the done flag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;while (DMA_TCD0_CSR &amp;amp; DMA_CSR_DONE_MASK)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Do I need any additional setup on UART side? Do I need these lines?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;UART0_C2 |= UART_C2_TIE_MASK;
UART0_C5 |= UART_C5_TDMAS_MASK;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5. How do I start a new transaction? Like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DMA_TCD0_CSR |= DMA_CSR_START_MASK;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 13:35:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1382668#M62003</guid>
      <dc:creator>john71</dc:creator>
      <dc:date>2021-12-07T13:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Transmiting a buffer on UART with DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1383808#M62031</link>
      <description>&lt;P&gt;Nobody knows how DMA works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 06:29:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1383808#M62031</guid>
      <dc:creator>john71</dc:creator>
      <dc:date>2021-12-09T06:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transmiting a buffer on UART with DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1388339#M62095</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/134631"&gt;@john71&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, I am very thankful for your patience.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, I would like to know, which mcu are you using for?&lt;/P&gt;
&lt;P&gt;Sharing with you a couple of threads of our community, where you can find accurate information on how DMA works. I would like to help you by telling you if the configuration of your registers with a question sign (//???) are configured ok, but it depends on your application needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hoping this links might be helpful:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/Kinetis-Microcontrollers/UART-DMA-Configuration/m-p/1166667" target="_blank"&gt;https://community.nxp.com/t5/Kinetis-Microcontrollers/UART-DMA-Configuration/m-p/1166667&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-K60-K70-configuration-of-DMA-with-I2S-RxCh0-RxCh1-on/td-p/359679" target="_blank"&gt;https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-K60-K70-configuration-of-DMA-with-I2S-RxCh0-RxCh1-on/td-p/359679&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At last but not least, regarding your other questions, the register DMA_TCD0_NBYTES_MLNO defines the number of bytes to transfer per request, so if you are going to change the data size to transfer in every request, you should update this register. For DMA interruption, you can refer to this link &lt;A href="https://community.nxp.com/t5/Kinetis-Microcontrollers/Interrupt-on-DMA-Completion/td-p/799501" target="_blank"&gt;Interrupt on DMA Completion&lt;/A&gt; where is being used a Kinetis&amp;nbsp; K27 Series. Lastly, I will suggest you to check our SDK Examples, by searching and downloading your mcu sdk here: &lt;A href="https://mcuxpresso.nxp.com/en/select" target="_blank"&gt;SDK Builder&lt;/A&gt;, where you can get functional examples on eDMA and DMA transfers in our MCUXpresso IDE.&lt;BR /&gt;&lt;BR /&gt;Please let me know if you have more questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards.&lt;/P&gt;
&lt;P&gt;Pablo Avalos.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:40:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1388339#M62095</guid>
      <dc:creator>PabloAvalos</dc:creator>
      <dc:date>2021-12-16T20:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: Transmiting a buffer on UART with DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1389086#M62114</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 19 Dec 2021 12:28:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Transmiting-a-buffer-on-UART-with-DMA/m-p/1389086#M62114</guid>
      <dc:creator>john71</dc:creator>
      <dc:date>2021-12-19T12:28:04Z</dc:date>
    </item>
  </channel>
</rss>

