<?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: SPI Using DMA Sends Duplicate Bytes... in Processor Expert Software</title>
    <link>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256752#M1576</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Ian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had the same problem, I solved the repeated byte problem activating the spi FIFO&amp;nbsp; (SPI1_C3 0x01)&amp;nbsp; in kinetis MKWZ01 before transmit, this way i think that the SPI system can handle correctly the DMA transfer, in this example I perform a 264 bytes TX transmit from RAM buffer to SPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope will be helpful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Nov 2015 22:04:56 GMT</pubDate>
    <dc:creator>joseplluismoral</dc:creator>
    <dc:date>2015-11-10T22:04:56Z</dc:date>
    <item>
      <title>SPI Using DMA Sends Duplicate Bytes...</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256748#M1572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using a Kinetis KL14 and am trying to implement the Proessor Expert SPI interface as Master. The device I am connecting to requires multiple bytes to be transferred without raising the CS pin in between bytes; therefore I believe I have to use the SPI interface with DMA so it can keep up - tt seems to ALMOST work, but I have noticed some strange behaviour...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have the SPI clock rate set to 1MHz, and I attempt to send 12 bytes of data, it actually sends 13 (confirmed with oscilloscope) and it is the first byte that is repeated twice. The sent data count reads as 12, and send status reads as complete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If, however, I have the clock rate set higher (e.g. 2MHz, 4Mhz) the same thing happens, HOWEVER only ever on the FIRST time.... repeated attempts will then always send the correct 12 bytes as expected. UNTIL I call the 'cancel transmission' function, at which point the problem resets; i.e. the first send is broken, subsequent sends work as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a slightly cryptic note in the reference manual which seems vaguely relevant:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;After DMA transfers the first byte to the SPI data register, the SPI pushes this data into&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;the shifter, thereby making SPTEF high again. This generates another DMA request&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;immediately, but the CPU lacks enough time to service the first DMA interrupt service&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;request (ISR). The subsequent DMA request is paced at the SPI transfer rate. Manage this&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;behavior during the first byte transfer through the DMA channel. Write the first byte to&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;the SPI data register via the CPU. The other bytes are transmitted by the DMA.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to suggest that the first byte should be handled differently, although I can not see whether this is happening in the PE generated code. I have attempted to manually send the first byte, however this leaves a long gap between the first byte and those that follow it, which is not acceptable for my implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess my question is: is there a known bug in the SPI DMA implementation, or am I just using it wrong? And if so, how do I implement a reasonably fast and reliable SPI Master interface....?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 17:12:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256748#M1572</guid>
      <dc:creator>icm</dc:creator>
      <dc:date>2014-01-24T17:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Using DMA Sends Duplicate Bytes...</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256749#M1573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;Could you provide some sample project showing the components settings and usage in code ?&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Petr Hradsky&lt;/P&gt;&lt;P&gt;Processor Expert Support Team&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 10:25:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256749#M1573</guid>
      <dc:creator>Petr_H</dc:creator>
      <dc:date>2014-01-30T10:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Re: SPI Using DMA Sends Duplicate Bytes...</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256750#M1574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as the code is concerned, I simply call the 'receive' and 'send' commands....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;memset(spiWriteBuffer, 0, SPI_DATA_SIZE+2) ;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;spiWriteBuffer[0] = 3 ; // Read command is 00000011&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;spiWriteBuffer[1] = tmpVal ; // Copy the SPI register address&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;EM&gt;// We don't need any more data for a read, so just start it&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;regData.status.spiStatus = SPI_STATUS_BUSY ;&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;if (ERR_OK != spiEth_ReceiveBlock(spiEth_DeviceData, spiReadBuffer, 10+2) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; regData.status.spiStatus = SPI_STATUS_READ_ERROR ;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;if ( ERR_OK != spiEth_SendBlock(spiEth_DeviceData, spiWriteBuffer, 10+2) ) // Need to send data to get a response...&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; regData.status.spiStatus = SPI_STATUS_READ_ERROR ;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and use the "OnBlockReceived" function to handle the returned data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a copy of the ProcessorExpert_Settings.xml for the SPI 'Bean' as I believe this shows all of the relevant settings....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since my original post I have looked into the auto-generated code in more detail, and it does not seem to follow the recommended process in the reference manual (Figure 34-22). I have attempted to modify this code to follow the recommended steps with some limited success - i.e. I can force it to always send the correct number of bytes, however the behaviour of the first transfer is still different to all subsequent transfers, until the 'cancel' function is called, even though the process claims to complete properly (since the 'on block sent/received) functions are called.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 11:03:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256750#M1574</guid>
      <dc:creator>icm</dc:creator>
      <dc:date>2014-01-30T11:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Using DMA Sends Duplicate Bytes...</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256751#M1575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We are not aware of any issues with this, and we would need more details on reproducing the issue, a simplified project showing the settings with a sample code would be the best.&lt;/P&gt;&lt;P&gt;Could you be more specific on why the "&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px;"&gt;auto-generated code" does not follow the reference manual?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Petr Hradsky&lt;/P&gt;&lt;P&gt;Processor Expert Support Team&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 10:31:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256751#M1575</guid>
      <dc:creator>Petr_H</dc:creator>
      <dc:date>2014-02-26T10:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Using DMA Sends Duplicate Bytes...</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256752#M1576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Ian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had the same problem, I solved the repeated byte problem activating the spi FIFO&amp;nbsp; (SPI1_C3 0x01)&amp;nbsp; in kinetis MKWZ01 before transmit, this way i think that the SPI system can handle correctly the DMA transfer, in this example I perform a 264 bytes TX transmit from RAM buffer to SPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope will be helpful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 22:04:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/SPI-Using-DMA-Sends-Duplicate-Bytes/m-p/256752#M1576</guid>
      <dc:creator>joseplluismoral</dc:creator>
      <dc:date>2015-11-10T22:04:56Z</dc:date>
    </item>
  </channel>
</rss>

