<?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: Long ~30uS delay between SPI byte transmissions in fsl_dspi during call to DSPI_DRV_MasterTransferBlocking(), what causes it? in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425057#M2317</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Chad Williams:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are sorry for the delay with no answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made some tests and your issue is probably caused by the SPI interrupt handling time. The MasterSetDelay function for &lt;EM&gt;kDspiAfterTransfer&lt;/EM&gt; applies between bytes transmitted from a FIFO, but in your case you are using SPI2 with FIFO size = 1, so each time a byte is transferred then an interrupt is generated and the next frame/byte is transmitted until the interrupt code provides a new byte.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some things you can try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-&lt;/STRONG&gt; Increase the core frequency. The MK24FN1M0VLL12 can work up to 120 MHz.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-&lt;/STRONG&gt; Change the compiler optimization (Properties -&amp;gt; C/C++ Build -&amp;gt; Settings -&amp;gt; Optimization -&amp;gt; Optimization level [-O1, -O2, -O3]).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-&lt;/STRONG&gt; Lower the SPI frequency if your LCD accepts it (e.g. to 1 MHz).&lt;/P&gt;&lt;P&gt;- Use SPI0, which has FIFO size of 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Playing with these options will give you a better timing to avoid LCD flickering.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Jun 2015 16:20:49 GMT</pubDate>
    <dc:creator>Jorge_Gonzalez</dc:creator>
    <dc:date>2015-06-15T16:20:49Z</dc:date>
    <item>
      <title>Long ~30uS delay between SPI byte transmissions in fsl_dspi during call to DSPI_DRV_MasterTransferBlocking(), what causes it?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425056#M2316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been testing an application that writes to an LCD using SPI and have noticed its slow and decided to look into the cause.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Processor MK24FN1M0120VLL&lt;/P&gt;&lt;P&gt;CPU clock 20.97152MHz&lt;/P&gt;&lt;P&gt;SPI clock rate&amp;nbsp; 2.097MHz&lt;/P&gt;&lt;P&gt;SPI intance&amp;nbsp;&amp;nbsp; DSPI2&amp;nbsp; ( 1 byte FIFO)&lt;/P&gt;&lt;P&gt;KSDK version 1.2.0 using Processor expert for driver configuration, KDS3.0&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the display data is being written in successive calls to :&lt;/P&gt;&lt;P&gt;dspiResult = DSPI_DRV_MasterTransferBlocking(FSL_DSPICOM1,NULL, pagebuf,NULL, bufindex+1, LCD_MASTER_TRANSFER_TIMEOUT);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;close inspection of the data being transmitted revealed there is about 32 microseconds delay between each byte&lt;/P&gt;&lt;P&gt;and each byte takes 3.8 microseconds&amp;nbsp; to transmit.&amp;nbsp; I want to significantly reduce this 32 uS delay in order to make display refresh activity&amp;nbsp; not visible to the user.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done some digging and found there are programmable delays&amp;nbsp; and have made a call to adjust the delay after transfer to 476nS&lt;/P&gt;&lt;P&gt;status = DSPI_DRV_MasterSetDelay(instance, kDspiAfterTransfer, 476, &amp;amp; calculatedDelayaftertransfer);&lt;/P&gt;&lt;P&gt;if (status != kStatus_DSPI_Success) return;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this code returns with kStatus_DSPI_Success but appears to have no effect.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since its a simple blocking write to SPI from a buffer, the code should write to SPI without significant delays. &lt;/P&gt;&lt;P&gt;Is there anything I should do to eliminate the delay between bytes?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached an image of the master configuration in PE&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2015 01:48:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425056#M2316</guid>
      <dc:creator>chadwilliams</dc:creator>
      <dc:date>2015-06-04T01:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Long ~30uS delay between SPI byte transmissions in fsl_dspi during call to DSPI_DRV_MasterTransferBlocking(), what causes it?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425057#M2317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Chad Williams:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are sorry for the delay with no answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made some tests and your issue is probably caused by the SPI interrupt handling time. The MasterSetDelay function for &lt;EM&gt;kDspiAfterTransfer&lt;/EM&gt; applies between bytes transmitted from a FIFO, but in your case you are using SPI2 with FIFO size = 1, so each time a byte is transferred then an interrupt is generated and the next frame/byte is transmitted until the interrupt code provides a new byte.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some things you can try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-&lt;/STRONG&gt; Increase the core frequency. The MK24FN1M0VLL12 can work up to 120 MHz.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-&lt;/STRONG&gt; Change the compiler optimization (Properties -&amp;gt; C/C++ Build -&amp;gt; Settings -&amp;gt; Optimization -&amp;gt; Optimization level [-O1, -O2, -O3]).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-&lt;/STRONG&gt; Lower the SPI frequency if your LCD accepts it (e.g. to 1 MHz).&lt;/P&gt;&lt;P&gt;- Use SPI0, which has FIFO size of 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Playing with these options will give you a better timing to avoid LCD flickering.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:20:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425057#M2317</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-06-15T16:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Long ~30uS delay between SPI byte transmissions in fsl_dspi during call to DSPI_DRV_MasterTransferBlocking(), what causes it?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425058#M2318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jorge,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for replying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have now obtain satisfactory performance with the LCD using SPI0 ( 4 byte fifo ) and non-blocking edma. The LCD is a 32 level grayscale 128x128 that required 32768 bytes/screen&amp;nbsp; when driven in 9 bit 3 wire SPI mode and 16384 bytes when driven in 4 wire 8bit mode. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In regards to the performance of DSPI2 using interrupts which I may use for communicating with other peripherals such as SPIflash, I would still want to optimize &lt;/P&gt;&lt;P&gt;performance. Here's some remarks from my testing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;-&lt;/STRONG&gt; Increase the core frequency. The MK24FN1M0VLL12 can work up to 120 MHz.&lt;/P&gt;&lt;P&gt;I attempted to get the CPU running on a core clock of around 95MHz and bus clock of 47.98MHz but ran into possible issues with JTAG communications so I was unable to test operation at that speed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;-&lt;/STRONG&gt; Change the compiler optimization (Properties -&amp;gt; C/C++ Build -&amp;gt; Settings -&amp;gt; Optimization -&amp;gt; Optimization level [-O1, -O2, -O3]).&lt;/P&gt;&lt;P&gt;with a 20MHz core clock and with optimization set to&amp;nbsp;&amp;nbsp; -O0 the time between bytes is&amp;nbsp; 32uS&amp;nbsp; with -O3&amp;nbsp; the time between bytes is 14uS .&lt;/P&gt;&lt;P&gt;In my opinion this is still too long for a blocking write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing about PEx/KSDK1.2.0&amp;nbsp; configuration with DSPI, I learned not to setup a DMA channel for SPI0TX signal, its not nessecary as the DSPI driver handles that.&lt;/P&gt;&lt;P&gt;If you do then you get skipped bytes in the SPI output....&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Chad&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 02:55:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Long-30uS-delay-between-SPI-byte-transmissions-in-fsl-dspi/m-p/425058#M2318</guid>
      <dc:creator>chadwilliams</dc:creator>
      <dc:date>2015-06-22T02:55:53Z</dc:date>
    </item>
  </channel>
</rss>

