<?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 slave with variable message length in S32K</title>
    <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961856#M5396</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;So when pin interrupt occurs you can't get all frames?&lt;/P&gt;&lt;P&gt;I suppose the root cause is the interrupt priorities. Pins interrupt priority is higher than lpspi interrupt. In this case when you get the rising edge on PCS some SPI frames are still in the hardware fifo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you try to use interrupt manager API to change the interrupts priorities for LPSPI and pins?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Razvan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Jun 2019 12:27:22 GMT</pubDate>
    <dc:creator>razva_tilimpea</dc:creator>
    <dc:date>2019-06-12T12:27:22Z</dc:date>
    <item>
      <title>SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961853#M5393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using S32K148EVB board.&lt;BR /&gt;The SW uses:&lt;BR /&gt;- FreeRTOS&lt;BR /&gt;- SPI slave (spi_pal with lpspi0 using DMA)&lt;BR /&gt;- additional Output pin PTA30 for Spi Slave to request the master to start SPI communication&lt;BR /&gt;- additional Input pin PTA6 for Spi Slave, connected to SPI CS pin and configure as interrupt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sending data from Slave to Master works fine.&lt;BR /&gt;Detecting CS pin change with PTA6 Interrupt works fine.&lt;/P&gt;&lt;P&gt;Our application protocol starts with 1 byte with value 0x55 and as variable length (with lenght indicated in the payload).&lt;/P&gt;&lt;P&gt;For reception I'm calling API SPI_SlaveTransfer(SPI_INSTANCE, slave_send, slave_receive, BUFFER_SIZE) and wait for the master to poll the SPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The issue is that we don't know in advance the size of the packet that the master will send.&lt;BR /&gt;So the spi callback will not be triggered unless all the bytes are received.&lt;/P&gt;&lt;P&gt;What would be the best solution for our case (being able to receive any length, any time)? Should we wait for CS to be disabled before reading the DMA rx buffer?&lt;/P&gt;&lt;P&gt;I would like to avoid modifying as much as possible the spi_pal and lpspi drivers provided in the SDK.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;There seems to be no clear answer from all the NXP Community thread I read:&lt;/P&gt;&lt;P&gt;my first thread: &lt;A href="https://community.nxp.com/message/1160105" target="test_blank"&gt;https://community.nxp.com/message/1160105&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/1123908" target="test_blank"&gt;https://community.nxp.com/message/1123908&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.nxp.com/message/1068750" target="test_blank"&gt;https://community.nxp.com/message/1068750&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2019 16:11:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961853#M5393</guid>
      <dc:creator>antoine_monmarc</dc:creator>
      <dc:date>2019-06-07T16:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961854#M5394</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;The solution for your problem is on second post.&lt;/P&gt;&lt;P&gt;Because the LPSPI hardware doesn't have any method to detect when CS is negated you must use another GPIO pin to monitor CS pin and when the transfer is done (CS switch from low to high) you can call transfer abort function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Razvan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2019 09:24:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961854#M5394</guid>
      <dc:creator>razva_tilimpea</dc:creator>
      <dc:date>2019-06-10T09:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961855#M5395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have implemented the CS pin detection IRQ. The CS pin state change works fine.&lt;/P&gt;&lt;P&gt;In the IRQ handler we are doing the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;static void spi_cs_detection(void)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; if(bIsSpiCsPinActive()==true)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; LPSPI_DRV_SlaveAbortTransfer(SPI_OVER_LPSPI00_INSTANCE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; memset(slave_receive, 0xFF, BUFFER_SIZE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; memset(slave_send, 0xFF, BUFFER_SIZE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; LPSPI_DRV_SlaveTransfer(SPI_OVER_LPSPI00_INSTANCE, slave_send, slave_receive, BUFFER_SIZE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; }&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; else&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; LPSPI_DRV_SlaveAbortTransfer(SPI_OVER_LPSPI00_INSTANCE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; LPSPI_DRV_ReadRXBuffer(SPI_OVER_LPSPI00_INSTANCE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; }&lt;/EM&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;EM&gt; PINS_DRV_ClearPinIntFlagCmd(SPI_CS_PORT, SPI_CS_PIN);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem is, the rxBuff is always truncated:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/86014i15835A6FDBA0C14B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_5.png" alt="pastedImage_5.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, we always get a LPSPI_TRANSMIT_ERROR in the&amp;nbsp;LPSPI_DRV_SlaveIRQHandler:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/86015iECA2F714B656BE6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_6.png" alt="pastedImage_6.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 11:44:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961855#M5395</guid>
      <dc:creator>antoine_monmarc</dc:creator>
      <dc:date>2019-06-12T11:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961856#M5396</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;So when pin interrupt occurs you can't get all frames?&lt;/P&gt;&lt;P&gt;I suppose the root cause is the interrupt priorities. Pins interrupt priority is higher than lpspi interrupt. In this case when you get the rising edge on PCS some SPI frames are still in the hardware fifo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you try to use interrupt manager API to change the interrupts priorities for LPSPI and pins?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Razvan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 12:27:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961856#M5396</guid>
      <dc:creator>razva_tilimpea</dc:creator>
      <dc:date>2019-06-12T12:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961857#M5397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are using the following configuration for interrupt&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;LPSPI_DRV_SlaveInit =&amp;gt;&amp;nbsp;INT_SYS_SetPriority(g_lpspiIrqId[instance], 2);&lt;/LI&gt;&lt;LI&gt;EDMA_DRV_Init =&amp;gt;&amp;nbsp;INT_SYS_SetPriority(irqNumber, 3);&lt;/LI&gt;&lt;LI&gt;GPIO Interrupt =&amp;gt; INT_SYS_SetPriority(SPI_CS_PORT_IRQn, 1);&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any combinaison will give the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FreeRTOSConfig.h:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY&amp;nbsp; 0x0F&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 0x01&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 12:53:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961857#M5397</guid>
      <dc:creator>antoine_monmarc</dc:creator>
      <dc:date>2019-06-12T12:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961858#M5398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Changing Interrupt priority like this will do the job:&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;LPSPI_DRV_SlaveInit =&amp;gt;&amp;nbsp;INT_SYS_SetPriority(g_lpspiIrqId[instance], 2);&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;EDMA_DRV_Init =&amp;gt;&amp;nbsp;INT_SYS_SetPriority(irqNumber, 1);&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;GPIO Interrupt =&amp;gt; INT_SYS_SetPriority(SPI_CS_PORT_IRQn, 3);&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calling the&amp;nbsp;&lt;EM style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;LPSPI_DRV_SlaveTransfer &lt;/EM&gt;function direclty in the IRQ handler will lost the first received byte. To avoid this, we call the&amp;nbsp;&lt;EM style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;LPSPI_DRV_SlaveTransfer &lt;/EM&gt;right after the transmission is complete (CS pin disabled) so it is ready for next time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 13:02:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961858#M5398</guid>
      <dc:creator>antoine_monmarc</dc:creator>
      <dc:date>2019-06-12T13:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961859#M5399</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;Ok I didn't know this that you are using the DMA mode, but the point is to abort the transfer only when you are sure that you have processed all frames.&lt;/P&gt;&lt;P&gt;Sorry for this workaround, but from hardware perspective is hard to know when to finish the transfer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Razvan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 13:29:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/961859#M5399</guid>
      <dc:creator>razva_tilimpea</dc:creator>
      <dc:date>2019-06-12T13:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: SPI slave with variable message length</title>
      <link>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/1568414#M19393</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;is this true also for dspi on MK6x kinetis microcontrollers with or without DMA enabled? To enable variable message len on dspi slave we need to use an external GPIO to signal received message has been totally sent?&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Michele&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 15:11:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/SPI-slave-with-variable-message-length/m-p/1568414#M19393</guid>
      <dc:creator>mdecandia</dc:creator>
      <dc:date>2022-12-12T15:11:29Z</dc:date>
    </item>
  </channel>
</rss>

