<?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>Kinetis MicrocontrollersのトピックRe: K22 SPI DMA master mode</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475367#M28906</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Catosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the following section, I think your understanding is correct, the SPIx_PUSHR register can be separated by the 16 bits COMMAMD register and 16 bits DATA register, you can write separately when the SPI is set up in master mode. You explanation is correct "&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;after you push the command word to the SPI module I can then send the data words with 8 bit writes without configuring the &lt;STRONG&gt;command&lt;/STRONG&gt; word for each &lt;STRONG&gt;data&lt;/STRONG&gt; word.". The DMA can only write the data register part of SPIx_PUSHR, the condition is that you have written the command register of SPIx_PUSHR before.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;BR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;XiangJun Rong&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.9.2.11 Writing SPI Transmit FIFO&lt;/P&gt;&lt;P&gt;The SPI supports 8-bit or 16-bit writes to the PUSH TX FIFO, allowing a single write to&lt;/P&gt;&lt;P&gt;the command word followed by multiple writes to the transmit word. The TX FIFO will&lt;/P&gt;&lt;P&gt;save the last command word written, and convert a 8-bit/16-bit write to the transmit word&lt;/P&gt;&lt;P&gt;into a 32-bit write that pushes both the command word and transmit word into the TX&lt;/P&gt;&lt;P&gt;FIFO (PUSH TX FIFO Register In Master Mode)&lt;/P&gt;&lt;P&gt;A 32-bit write to the SPI_PUSH register will push all 32-bits to the TX FIFO. An 8-bit or&lt;/P&gt;&lt;P&gt;16-bit write to the 16-bit transmit data field will push the data together with the last&lt;/P&gt;&lt;P&gt;written command word. An 8-bit or 16-bit write to the command word does not push data&lt;/P&gt;&lt;P&gt;onto the FIFO, but that command word is pushed to the TX FIFO on all subsequent 8-bit&lt;/P&gt;&lt;P&gt;or 16-bit writes to the transmit data field. This allows a single 16-bit write to the&lt;/P&gt;&lt;P&gt;command word to be used for all subsequent 8-bit or 16-bit writes to the transmit data&lt;/P&gt;&lt;P&gt;word. Writing a different 16-bit command word will cause all subsequent 8-bit or 16-bit&lt;/P&gt;&lt;P&gt;writes to the transmit data word to be pushed to the TX FIFO with the new command&lt;/P&gt;&lt;P&gt;word.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Dec 2015 06:22:21 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2015-12-11T06:22:21Z</dc:date>
    <item>
      <title>K80 SPI DMA master mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475365#M28904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;Hello, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;I know there are already other discussion out there about this topic.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt; Anyway, there are a couple of question I can't get straight right now, so I would like some kind of feedback from the community. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;According to the the very helpful post by &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-102981"&gt;Adrian Sanchez Cano &lt;/A&gt;​(Using DMA and SPI.pdf) he asserts that "&lt;SPAN style="color: #000000;"&gt;To ensure the synchrony between the dSPI with the DMA the transfers to the PUSHR must be of 4 bytes, this includes 2 bytes command and 2 bytes data&lt;/SPAN&gt;".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Furthermore, looking at the examples provided (ok, I saw the K20 one, but I think that k80 and k20 are identical for SPI and DMA) we have to prepare the buffer &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;(MasterDataSend() function) and then send the prepared buffer. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;In my opinion this inserts an heavy overhead on the overall budget of the CPU time. My question is: Can we do better, using eDMA without having to prepare that buffer for every byte we have to send?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Looking at the SPI module, &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 14pt; font-family: TimesLTStd-Roman;"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: TimesLTStd-Roman; font-size: 14pt; color: #000000;"&gt;The SPI supports 8-bit or 16-bit writes to the PUSH TX FIFO, allowing &lt;STRONG&gt;a single write to &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 14pt; font-family: TimesLTStd-Roman;"&gt;&lt;STRONG&gt;the command word followed by multiple writes to the transmit word&lt;/STRONG&gt;. The &lt;STRONG&gt;TX FIFO will &lt;/STRONG&gt;&lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;save the last command word written, and convert a 8-bit/16-bit write to the transmit word &lt;SPAN style="font-size: 14pt;"&gt;into a 32-bit write that pushes both the command word and transmit word into the TX &lt;SPAN style="font-size: 14pt;"&gt;FIFO.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 14pt; font-family: TimesLTStd-Roman;"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;In my understanding, after I push the command word to the SPI module I can then send the data words with 8 bit writes without configuring the &lt;STRONG&gt;command&lt;/STRONG&gt; word for each &lt;STRONG&gt;data&lt;/STRONG&gt; word.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;The eDMA allows the transfer of 8 bytes according to &lt;STRONG&gt;DMA_TCDn_ATTR&lt;/STRONG&gt;[&lt;STRONG&gt;SSIZE&lt;/STRONG&gt;] &amp;amp; &lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;&lt;STRONG&gt;DMA_TCDN_ATTR[DSIZE].&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;Disabling minor loop mapping I can set &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 13.3333px;"&gt;&lt;STRONG&gt;DMA_TCDn_NBYTES_MLNO&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt; to &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 13.3333px;"&gt;&lt;STRONG&gt;Nbytes&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;, so I can configure the number of bytes to transfer per request. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;So the idea is to set the command word, then using DMA send &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 13.3333px;"&gt;&lt;STRONG&gt;length-1 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;bytes and when the DMA asserts an EOQ IRQ, I can configure the SPI command word for the last byte to be &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px; line-height: 20px;"&gt;transferred&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;Somehow, I suppose that if this was feasible somewhere in the forum it should have been pointed out, and guess what? It is not.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;SO I suppose there are many flaws in my idea. I don't want to begin to implement something that is proven will not work (wasting a lots [debug] time) , so I'm asking you: &lt;BR /&gt;is this &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px; line-height: 20px;"&gt;feasible&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;? Or, in your opinion, why not?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;is the procedure suggested by Adrian the &lt;STRONG&gt;only&lt;/STRONG&gt; way, or the &lt;STRONG&gt;best&lt;/STRONG&gt; way of using SPI and DMA in kinetis microcontrollers?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Best regards, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Luca.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Messaggio modificato da luca toso&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Dec 2015 15:27:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475365#M28904</guid>
      <dc:creator>Catosh</dc:creator>
      <dc:date>2015-12-10T15:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: K22 SPI DMA master mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475366#M28905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The verbiage you quoted is 'new to me'!&amp;nbsp; I am not aware of such 'follow-on command-code copy', although that certainly MAKES SENSE!&amp;nbsp; Wonder if that is a new 'mask specific' improvement in some way....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My solution to the problem is simply to organize the usage of the 'outbound buffer' so that the 'data source' simply knows to write only the least-byte of each 4-byte allocation, leaving the rest 'as initialized' for ALL subsequent DMA block-transfers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Dec 2015 18:36:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475366#M28905</guid>
      <dc:creator>egoodii</dc:creator>
      <dc:date>2015-12-10T18:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: K22 SPI DMA master mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475367#M28906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Catosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the following section, I think your understanding is correct, the SPIx_PUSHR register can be separated by the 16 bits COMMAMD register and 16 bits DATA register, you can write separately when the SPI is set up in master mode. You explanation is correct "&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;after you push the command word to the SPI module I can then send the data words with 8 bit writes without configuring the &lt;STRONG&gt;command&lt;/STRONG&gt; word for each &lt;STRONG&gt;data&lt;/STRONG&gt; word.". The DMA can only write the data register part of SPIx_PUSHR, the condition is that you have written the command register of SPIx_PUSHR before.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;BR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #000000;"&gt;XiangJun Rong&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.9.2.11 Writing SPI Transmit FIFO&lt;/P&gt;&lt;P&gt;The SPI supports 8-bit or 16-bit writes to the PUSH TX FIFO, allowing a single write to&lt;/P&gt;&lt;P&gt;the command word followed by multiple writes to the transmit word. The TX FIFO will&lt;/P&gt;&lt;P&gt;save the last command word written, and convert a 8-bit/16-bit write to the transmit word&lt;/P&gt;&lt;P&gt;into a 32-bit write that pushes both the command word and transmit word into the TX&lt;/P&gt;&lt;P&gt;FIFO (PUSH TX FIFO Register In Master Mode)&lt;/P&gt;&lt;P&gt;A 32-bit write to the SPI_PUSH register will push all 32-bits to the TX FIFO. An 8-bit or&lt;/P&gt;&lt;P&gt;16-bit write to the 16-bit transmit data field will push the data together with the last&lt;/P&gt;&lt;P&gt;written command word. An 8-bit or 16-bit write to the command word does not push data&lt;/P&gt;&lt;P&gt;onto the FIFO, but that command word is pushed to the TX FIFO on all subsequent 8-bit&lt;/P&gt;&lt;P&gt;or 16-bit writes to the transmit data field. This allows a single 16-bit write to the&lt;/P&gt;&lt;P&gt;command word to be used for all subsequent 8-bit or 16-bit writes to the transmit data&lt;/P&gt;&lt;P&gt;word. Writing a different 16-bit command word will cause all subsequent 8-bit or 16-bit&lt;/P&gt;&lt;P&gt;writes to the transmit data word to be pushed to the TX FIFO with the new command&lt;/P&gt;&lt;P&gt;word.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Dec 2015 06:22:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475367#M28906</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2015-12-11T06:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: K80 SPI DMA master mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475368#M28907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;EARL GOODRICH ha scritto:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The verbiage you quoted is 'new to me'!&amp;nbsp; I am not aware of such 'follow-on command-code copy', although that certainly MAKES SENSE!&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Sorry, My fault. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I messed up different part numbers, and obviously they weren't identical. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I was reading the datasheet of the K80 mcu and watching the K20 examples. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I modified original post to reflect the correct part number. &lt;BR /&gt;But the question still remains: in k80 I can use the lower bits of the fifo, while on k64 the pre-buffering seems to be a little bit inefficient. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Dec 2015 08:09:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K80-SPI-DMA-master-mode/m-p/475368#M28907</guid>
      <dc:creator>Catosh</dc:creator>
      <dc:date>2015-12-11T08:09:54Z</dc:date>
    </item>
  </channel>
</rss>

