<?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 LPC844 - SPI sending 2 frames in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1295637#M45568</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I try to send 2 frames, each of 8 bits. I want to do this without the SSEL line to go high between frames. It is active low.&lt;/P&gt;&lt;P&gt;I have attached my code below.&lt;/P&gt;&lt;P&gt;Going through the datasheet it seems that I have to change the EOT bit to 0 for the first byte. Then EOT need to be sat to 1 with the transmit of the second byte.&lt;/P&gt;&lt;P&gt;But it does not work. My code just hangs and there is no transmit.&lt;/P&gt;&lt;P&gt;It works fine transmitting 1 frame&lt;/P&gt;&lt;P&gt;Any advice?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;void spi_setup()&lt;BR /&gt;{&lt;BR /&gt;SYSCON-&amp;gt;SYSAHBCLKCTRL0 |= (1&amp;lt;&amp;lt;11); //Enable clock for SPI0&lt;/P&gt;&lt;P&gt;SWM0-&amp;gt;PINASSIGN_DATA[3] &amp;amp;= ~(0xFF&amp;lt;&amp;lt;24);&lt;BR /&gt;SWM0-&amp;gt;PINASSIGN_DATA[3] |= (25&amp;lt;&amp;lt;24); //Assign SCK to GPIO0_25&lt;/P&gt;&lt;P&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] &amp;amp;= ~(0xFF&amp;lt;&amp;lt;0);&lt;BR /&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] |= (27&amp;lt;&amp;lt;0); //Assign MOSI to GPIO0_27&lt;/P&gt;&lt;P&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] &amp;amp;= ~(0xFF&amp;lt;&amp;lt;16);&lt;BR /&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] |= (26&amp;lt;&amp;lt;16); //Assign SSEL0 to GPIO0_26&lt;/P&gt;&lt;P&gt;SYSCON-&amp;gt;FCLKSEL[9] = 1; //Select Main_clk as source for SPI0&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;DIV = 10;&lt;BR /&gt;SPI0-&amp;gt;CFG = (1 &amp;lt;&amp;lt; 0) | // Enable SPI0&lt;BR /&gt;(1 &amp;lt;&amp;lt; 2) | // Master mode&lt;BR /&gt;(0 &amp;lt;&amp;lt; 3) | // LSB First mode disabled&lt;BR /&gt;(0 &amp;lt;&amp;lt; 4) | // CPHA = 0&lt;BR /&gt;(0 &amp;lt;&amp;lt; 5) | // CPOL = 0&lt;BR /&gt;(0 &amp;lt;&amp;lt; 8); // SPOL = 0&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;DLY |= (2&amp;lt;&amp;lt;8); // Frame delay = 2 SPI clock cycles&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;TXCTL = (1 &amp;lt;&amp;lt; 20) | // set End Of Transfer&lt;BR /&gt;(1 &amp;lt;&amp;lt; 21) | // set End Of Frame&lt;BR /&gt;(1 &amp;lt;&amp;lt; 22) | // RXIGNORE, otherwise SPI hangs until&lt;BR /&gt;// we read the data register&lt;BR /&gt;((8 - 1) &amp;lt;&amp;lt; 24); // 8 bit frames&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void spi_tx(unsigned char data)&lt;BR /&gt;{&lt;BR /&gt;// Wait for MSTIDLE, should be a no-op since we are waiting after&lt;BR /&gt;// the transfer.&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 8)));&lt;/P&gt;&lt;P&gt;// Wait for TXRDY&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 1)));&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;TXDATCTL = (0&amp;lt;&amp;lt;21)|(0&amp;lt;&amp;lt;20)|(data&amp;lt;&amp;lt;0);&lt;/P&gt;&lt;P&gt;// Wait for the transfer to finish&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 8)));&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;TXDATCTL = (1&amp;lt;&amp;lt;20)|(data&amp;lt;&amp;lt;0);&lt;/P&gt;&lt;P&gt;//SPI0-&amp;gt;TXDAT = data;&lt;/P&gt;&lt;P&gt;// Wait for the transfer to finish&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 8)));&lt;/P&gt;&lt;P&gt;// Force END OF TRANSFER&lt;BR /&gt;SPI0-&amp;gt;STAT = (1 &amp;lt;&amp;lt; 7);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jun 2021 20:34:48 GMT</pubDate>
    <dc:creator>tyassin1</dc:creator>
    <dc:date>2021-06-21T20:34:48Z</dc:date>
    <item>
      <title>LPC844 - SPI sending 2 frames</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1295637#M45568</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I try to send 2 frames, each of 8 bits. I want to do this without the SSEL line to go high between frames. It is active low.&lt;/P&gt;&lt;P&gt;I have attached my code below.&lt;/P&gt;&lt;P&gt;Going through the datasheet it seems that I have to change the EOT bit to 0 for the first byte. Then EOT need to be sat to 1 with the transmit of the second byte.&lt;/P&gt;&lt;P&gt;But it does not work. My code just hangs and there is no transmit.&lt;/P&gt;&lt;P&gt;It works fine transmitting 1 frame&lt;/P&gt;&lt;P&gt;Any advice?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;void spi_setup()&lt;BR /&gt;{&lt;BR /&gt;SYSCON-&amp;gt;SYSAHBCLKCTRL0 |= (1&amp;lt;&amp;lt;11); //Enable clock for SPI0&lt;/P&gt;&lt;P&gt;SWM0-&amp;gt;PINASSIGN_DATA[3] &amp;amp;= ~(0xFF&amp;lt;&amp;lt;24);&lt;BR /&gt;SWM0-&amp;gt;PINASSIGN_DATA[3] |= (25&amp;lt;&amp;lt;24); //Assign SCK to GPIO0_25&lt;/P&gt;&lt;P&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] &amp;amp;= ~(0xFF&amp;lt;&amp;lt;0);&lt;BR /&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] |= (27&amp;lt;&amp;lt;0); //Assign MOSI to GPIO0_27&lt;/P&gt;&lt;P&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] &amp;amp;= ~(0xFF&amp;lt;&amp;lt;16);&lt;BR /&gt;SWM0-&amp;gt;PINASSIGN_DATA[4] |= (26&amp;lt;&amp;lt;16); //Assign SSEL0 to GPIO0_26&lt;/P&gt;&lt;P&gt;SYSCON-&amp;gt;FCLKSEL[9] = 1; //Select Main_clk as source for SPI0&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;DIV = 10;&lt;BR /&gt;SPI0-&amp;gt;CFG = (1 &amp;lt;&amp;lt; 0) | // Enable SPI0&lt;BR /&gt;(1 &amp;lt;&amp;lt; 2) | // Master mode&lt;BR /&gt;(0 &amp;lt;&amp;lt; 3) | // LSB First mode disabled&lt;BR /&gt;(0 &amp;lt;&amp;lt; 4) | // CPHA = 0&lt;BR /&gt;(0 &amp;lt;&amp;lt; 5) | // CPOL = 0&lt;BR /&gt;(0 &amp;lt;&amp;lt; 8); // SPOL = 0&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;DLY |= (2&amp;lt;&amp;lt;8); // Frame delay = 2 SPI clock cycles&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;TXCTL = (1 &amp;lt;&amp;lt; 20) | // set End Of Transfer&lt;BR /&gt;(1 &amp;lt;&amp;lt; 21) | // set End Of Frame&lt;BR /&gt;(1 &amp;lt;&amp;lt; 22) | // RXIGNORE, otherwise SPI hangs until&lt;BR /&gt;// we read the data register&lt;BR /&gt;((8 - 1) &amp;lt;&amp;lt; 24); // 8 bit frames&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void spi_tx(unsigned char data)&lt;BR /&gt;{&lt;BR /&gt;// Wait for MSTIDLE, should be a no-op since we are waiting after&lt;BR /&gt;// the transfer.&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 8)));&lt;/P&gt;&lt;P&gt;// Wait for TXRDY&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 1)));&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;TXDATCTL = (0&amp;lt;&amp;lt;21)|(0&amp;lt;&amp;lt;20)|(data&amp;lt;&amp;lt;0);&lt;/P&gt;&lt;P&gt;// Wait for the transfer to finish&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 8)));&lt;/P&gt;&lt;P&gt;SPI0-&amp;gt;TXDATCTL = (1&amp;lt;&amp;lt;20)|(data&amp;lt;&amp;lt;0);&lt;/P&gt;&lt;P&gt;//SPI0-&amp;gt;TXDAT = data;&lt;/P&gt;&lt;P&gt;// Wait for the transfer to finish&lt;BR /&gt;while (!(SPI0-&amp;gt;STAT &amp;amp; (1 &amp;lt;&amp;lt; 8)));&lt;/P&gt;&lt;P&gt;// Force END OF TRANSFER&lt;BR /&gt;SPI0-&amp;gt;STAT = (1 &amp;lt;&amp;lt; 7);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:34:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1295637#M45568</guid>
      <dc:creator>tyassin1</dc:creator>
      <dc:date>2021-06-21T20:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: LPC844 - SPI sending 2 frames</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1296034#M45579</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;
&lt;P&gt;Recommend you refer to the SPI demo under SDK.&lt;/P&gt;
&lt;P&gt;And if still can't maintain low, directly use gpio to control slave selection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 09:04:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1296034#M45579</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-06-22T09:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: LPC844 - SPI sending 2 frames</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1310696#M45916</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I got it to work without the example code.&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 20:07:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC844-SPI-sending-2-frames/m-p/1310696#M45916</guid>
      <dc:creator>tyassin1</dc:creator>
      <dc:date>2021-07-20T20:07:40Z</dc:date>
    </item>
  </channel>
</rss>

