<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: DMA TX to Serial</title>
		<link>http://forums.leaflabs.com/topic.php?id=883</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:15:30 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=883" rel="self" type="application/rss+xml" />

		<item>
			<title>anotherDJ on "DMA TX to Serial"</title>
			<link>http://forums.leaflabs.com/topic.php?id=883#post-5661</link>
			<pubDate>Thu, 14 Jul 2011 22:21:38 +0000</pubDate>
			<dc:creator>anotherDJ</dc:creator>
			<guid isPermaLink="false">5661@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;WOW thanks everybody!&#60;/p&#62;
&#60;p&#62;thanks alot! I needed to get a few other things working for the project first so I put this on the back burner for the next milestone. All your help will not be wasted. I just caught up in the other stuff so didn't check the forum out in a while.&#60;/p&#62;
&#60;p&#62;cheers!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "DMA TX to Serial"</title>
			<link>http://forums.leaflabs.com/topic.php?id=883#post-5456</link>
			<pubDate>Wed, 29 Jun 2011 16:11:35 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5456@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;It should be noted that if you want to use dma_get_irq_cause() in the way robodude666 indicates, you'll also need to pass dma_setup_transfer() the flags DMA_TRNS_ERR, DMA_HALF_TRNS, and DMA_TRNS_CMPLT in addition to the other ones I mentioned in my first post.  Looks like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;dma_setup_transfer( ... as before ...,
                   (DMA_FROM_MEM   &#124;
                    DMA_MINC_MODE  &#124;
                    DMA_TRNS_ERR   &#124;
                    DMA_HALF_TRNS  &#124;
                    DMA_TRNS_CMPLT &#124;
                    &#38;lt;any other mode flags you want; see dma_mode_flags&#38;gt;));&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>robodude666 on "DMA TX to Serial"</title>
			<link>http://forums.leaflabs.com/topic.php?id=883#post-5453</link>
			<pubDate>Wed, 29 Jun 2011 15:31:41 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5453@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;And, because interrupts work now you can find out when the transfer completes:&#60;/p&#62;
&#60;p&#62;1) Attach the interrupt:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;dma_attach_interrupt(DMA1, DMA_CH4, dma_irq);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;2) Create your interrupt handler:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void dma_irq()
{
	dma_irq_cause cause = dma_get_irq_cause(DMA1, DMA_CH4);

	switch(cause)
	{
		case DMA_TRANSFER_COMPLETE:
			// Transfer completed
			break;
		case DMA_TRANSFER_HALF_COMPLETE:
			// Transfer is half complete
			break;
		case DMA_TRANSFER_ERROR:
			// An error occurred during transfer
			break;
		default:
			// Something went horribly wrong.
			// Should never happen.
			break;
	}

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The half complete interrupt, while it may look silly to have, is actually very cool. It allows you to know when half of the transfer is completed. Knowing this can be useful so that you can full the first half of the buffer with new data when you're using circular mode, or to prepare new resources for when the complete interrupt is called.&#60;/p&#62;
&#60;p&#62;Calling &#60;code&#62;dma_get_irq_cause&#60;/code&#62; will clear the irq bits, which are also cleared after your interrupt finishes running so there's no need to call &#60;code&#62;dma_clear_isr_bits&#60;/code&#62; manually.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "DMA TX to Serial"</title>
			<link>http://forums.leaflabs.com/topic.php?id=883#post-5451</link>
			<pubDate>Wed, 29 Jun 2011 15:14:34 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5451@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;There are some general notes on using dma.h in the wiki:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://wiki.leaflabs.com/index.php?title=DMA&#34; rel=&#34;nofollow&#34;&#62;http://wiki.leaflabs.com/index.php?title=DMA&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Here is some information on using USART1 TX with DMA (untested):&#60;/p&#62;
&#60;p&#62;If you're transferring to serial 1 TX, then the peripheral address is &#38;amp;USART1_BASE-&#38;gt;DR, and the DMA channel is 4 (on DMA1).  If you're just DMAing a byte buffer to USART, then the call to dma_setup_transfer() should probably look something like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;dma_setup_transfer(DMA1, DMA_CH4,
                   &#38;amp;USART1_BASE-&#38;gt;DR, DMA_SIZE_8BITS,
                   your_byte_buffer, DMA_SIZE_8BITS,
                   (DMA_FROM_MEM  &#124;
                    DMA_MINC_MODE &#124;
                    &#38;lt;any other mode flags you want; see dma_mode_flags&#38;gt;));&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;For a one-off transfer, you'll want to tell the DMA controller how many bytes you want to send, like so:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;dma_set_num_transfers(DMA1, DMA_CH4, &#38;lt;number of bytes in your_byte_buffer&#38;gt;);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;If you want to automatically loop back to the beginning of the buffer and go again, give dma_setup_transfer() the DMA_CIRC_MODE flag.&#60;/p&#62;
&#60;p&#62;In order to enable DMA transmission with TX, you'll need to set the DMAT bit in USART1_CR3:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;USART1_BASE-&#38;gt;CR3 &#124;= USART_CR3_DMAT;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Let us know how you get along!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>anotherDJ on "DMA TX to Serial"</title>
			<link>http://forums.leaflabs.com/topic.php?id=883#post-5426</link>
			<pubDate>Mon, 27 Jun 2011 23:38:35 +0000</pubDate>
			<dc:creator>anotherDJ</dc:creator>
			<guid isPermaLink="false">5426@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi All,&#60;/p&#62;
&#60;p&#62;just wondering if anyone has gotten the the DMA to transfer data array/memory to Serial1? if anyone could point me to an example, or documentation/how-to for using the dma.c and dma.h files for tx would be very helpful. the only example I found is for receiving from a Serial port.&#60;/p&#62;
&#60;p&#62;I tried playing around with it, to make it do TX but i didn't have much luck (more like any luck) with it.&#60;/p&#62;
&#60;p&#62;so any help would be much appreciated.&#60;/p&#62;
&#60;p&#62;thanks,
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
