<?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 Re: K64 SPI using DMA in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664217#M40822</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See Update in my original post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Jul 2017 13:58:32 GMT</pubDate>
    <dc:creator>JHinkle</dc:creator>
    <dc:date>2017-07-24T13:58:32Z</dc:date>
    <item>
      <title>K64 SPI using DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664215#M40820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've had SPI with interrupts working for some time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to look into using DMA so the cpu can continue working while the SPI is being serviced.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to provide the 16 data + 16 bit command word to the SPI via DMA without doubling the buffer size by including the SPI cmd info in the data stream?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems to be of questionable use. &amp;nbsp;Use DMA and take up twice the amount of ram to hold the data (16 bits of data + 16 bits of CMD) or service the SPI via an interrupt where the IRQ service provides the CMD and the ram buffer just holds data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any comments are welcomed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE: - July 2017&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I finally got it working - here's what I did.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had resigned myself that DMA was not usable in my application (K64 needed to transfer 8k of data to a KL17 every 25 msec at a SPI baud of 12 mhz). &amp;nbsp;I was using interrupts and all was well but I was not using the cpu efficiently.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;July 2017, I re-approached the issue again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reading Earl Goodrich's comment below and reading the suggested documentation suggested that SOME Kinetis micros would allow their&amp;nbsp;&amp;nbsp;SPI to be processed with DMA - having DMA only update the 16bit data portion of the SPI PUSHR register thereby maintaining the 16bit control word first written to kick off the SPI transfer. &amp;nbsp;The current K64 manual has wording that suggests that it would work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got DMA working by having DMA move 32bit words (my 16bit data + 16bit control) - works well but changed my ram requirements from 8k to 16k which was unacceptable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried for hours to have DMA only update the SPI data but the DMA SPI update would always set the control word to zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is that the K64 SPI requires 32 bits of data for each transfer (8/16 data + 16 control). &amp;nbsp;The control word contains which chip select is to be utilized. &amp;nbsp;The KL17 SPI is in slave mode and requires the chip select to operate -- but using DMA on the K64 resulted in the chip select being active for the first transfer (kicked off by software and DMA doing the remainder) -- once DMA took over, the chip select died (SPI control word set to zero).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here is how to get the K64 working with DMA -- transferring 8 or 16 bit data packets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DON'T use the SPI chip select on the master (K64 SPI)!!!!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When setting up the cpu's port definitions, instead of having the SPI's chip select pins MUX'd to SPI - set them to general purpose OUTPUT I/O.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Manually control the SPI's chip select in software. &amp;nbsp;I drive the chip select pin low before starting the SPI DMA transfer and set the chip select pin hi in the DMA's interrupt code upon DMA completion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very clean - works well - and no additional memory required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just thought I'd share.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2016 00:40:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664215#M40820</guid>
      <dc:creator>JHinkle</dc:creator>
      <dc:date>2016-10-25T00:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: K64 SPI using DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664216#M40821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have done the 'doubled up buffer' approach on K60 to refresh a monochrome OLED display, and in that case from a 'fixed allocation buffer' specifically so I could use bit-banding to draw pixels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will find that SOME (like K80?) of the Kinetis SPI documentation specifically list a (new???) mode whereby a lower- 8/16-bit write will 'repeat the last' upper-16 bits, and in THOSE devices you should be able to 'start the first' manually with the command bits you need, and let DMA run the rest as pure 8or16. See also:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/381726"&gt;K80 SPI DMA master mode&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 21:36:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664216#M40821</guid>
      <dc:creator>egoodii</dc:creator>
      <dc:date>2016-10-26T21:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: K64 SPI using DMA</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664217#M40822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See Update in my original post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 13:58:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-SPI-using-DMA/m-p/664217#M40822</guid>
      <dc:creator>JHinkle</dc:creator>
      <dc:date>2017-07-24T13:58:32Z</dc:date>
    </item>
  </channel>
</rss>

