<?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: SSP sending out data 7.5 bits behind, LPC1114 in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548828#M10709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by coryrc on Thu May 12 15:29:55 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow, Zero, thank you so much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Zero&lt;/STRONG&gt;&lt;BR /&gt;Can't confirm that:&lt;BR /&gt;&lt;BR /&gt;1. Changing CPHA changes capturing as decribed in manual and as expected.&lt;BR /&gt;&lt;BR /&gt;2. Your code is working, if you don't transmit Data too fast. Don't know why you've deleted the SSPSR_BSY check, but ignoring busy state doesn't make your code more reliable.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I took out the busy check because I intended to send data asynchronously without interrupts in the future, and I wanted to be able to queue up several bytes before running some other operations (16us*#bytes*send_rate adds up to a lot of time!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But your confirmation that the setup code is correct is so helpful! Adding the busy check back in didn't help. I am going to make another project to test just the SPI functionality.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 22:07:45 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T22:07:45Z</dc:date>
    <item>
      <title>SSP sending out data 7.5 bits behind, LPC1114</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548826#M10707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by coryrc on Wed May 11 17:15:56 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a very weird problem with SSP in SPI mode, CPHA/CPOL == 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Data seems to usually come out 7.5 or 8.5 bits after they are supposed to. The data is being changed on the up clock instead of the down clock, regardless of the CPHA/CPOL settings. I am only sending 8 bits at a time. When I send out a byte, the previous byte that was written to LPC_SSP0-&amp;gt;DR appears on the output! I know this for sure because I put my oscilloscope on clock and data, then breakpoint on LPC_SSP0-&amp;gt;DR = *buf. I see *buf equals say, 0x6. I'll do one step and the last thing written pops out! I go through again, and next time 0x6 will pop out instead of what's being written that time. This also happens free-running as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I set it to 16 bit mode, everything is shifted only 8 bits backward (so the upper 8 bits are the lower 8 bits of the previous transmission) instead of 16 bits, as you might expect if there was some TXFIFO issue of some sort.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sometimes after a compile/debug it starts working for a little while, but if I remove power and reapply it stops working. I've tried two different boards (both LPC1114/301). Here's my SSP setup:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp; LPC_SYSCON-&amp;gt;PRESETCTRL |= (0x1&amp;lt;&amp;lt;0);
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (0x1&amp;lt;&amp;lt;11);
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SYSCON-&amp;gt;SSP0CLKDIV = 0x06;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Divided by 6 */
&amp;nbsp; LPC_IOCON-&amp;gt;PIO0_8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;= ~0x07;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&amp;nbsp; SSP I/O config */
&amp;nbsp; LPC_IOCON-&amp;gt;PIO0_8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |= 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* SSP MISO */
&amp;nbsp; LPC_IOCON-&amp;gt;PIO0_9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;= ~0x07;
&amp;nbsp; LPC_IOCON-&amp;gt;PIO0_9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |= 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* SSP MOSI */

&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_IOCON-&amp;gt;SCK_LOC = 0x02;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_IOCON-&amp;gt;PIO0_6 = 0xD2;

&amp;nbsp; /* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 7 */
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;CR0 = 0x0707;

&amp;nbsp; /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;CPSR = 0x2;

&amp;nbsp; /* Master mode */
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;CR1 = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;CR1 = SSPCR1_SSE;
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;For sending, I do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp; for ( i = 0; i &amp;lt; Length; i++ ) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Move on only if TX FIFO not full. */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( (LPC_SSP0-&amp;gt;SR &amp;amp; SSPSR_TNF) != SSPSR_TNF );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;DR = *buf;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf++;
&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Wait until the Busy bit is cleared. */
&amp;nbsp; while ( LPC_SSP0-&amp;gt;SR &amp;amp; SSPSR_BSY );&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm running 12Mhz system clock (direct from IRC) and SPI clock is ~500kHz as measured.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any guesses? Any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:07:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548826#M10707</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: SSP sending out data 7.5 bits behind, LPC1114</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548827#M10708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu May 12 02:59:41 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Can't confirm that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Changing CPHA changes capturing as decribed in manual and as expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Your code is working, if you don't transmit Data too fast. Don't know why you've deleted the SSPSR_BSY check, but ignoring busy state doesn't make your code more reliable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. So my Serial Decoding Scope and Debugger are confirming that this code is working and data are transmitted correct &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
void spi_send(unsigned char* buf, unsigned int Length)
{
 unsigned int i;
 for ( i = 0; i &amp;lt; Length; i++ ) {
 while ( (LPC_SSP0-&amp;gt;SR &amp;amp; (SSPSR_TNF|SSPSR_BSY)) != SSPSR_TNF );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;DR = *buf;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf++;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The attached picture shows the same data buffer in scope and debugger after transmission:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.flickr.com/photos/58892165@N08/5712320315/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:07:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548827#M10708</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: SSP sending out data 7.5 bits behind, LPC1114</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548828#M10709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by coryrc on Thu May 12 15:29:55 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow, Zero, thank you so much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Zero&lt;/STRONG&gt;&lt;BR /&gt;Can't confirm that:&lt;BR /&gt;&lt;BR /&gt;1. Changing CPHA changes capturing as decribed in manual and as expected.&lt;BR /&gt;&lt;BR /&gt;2. Your code is working, if you don't transmit Data too fast. Don't know why you've deleted the SSPSR_BSY check, but ignoring busy state doesn't make your code more reliable.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I took out the busy check because I intended to send data asynchronously without interrupts in the future, and I wanted to be able to queue up several bytes before running some other operations (16us*#bytes*send_rate adds up to a lot of time!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But your confirmation that the setup code is correct is so helpful! Adding the busy check back in didn't help. I am going to make another project to test just the SPI functionality.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:07:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548828#M10709</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: SSP sending out data 7.5 bits behind, LPC1114</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548829#M10710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by coryrc on Thu May 12 19:24:39 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I found the problem, same as the other guy I searched for and found he had the same problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was measuring at the wrong point -- output of the shift register. When I would occasionally measure somewhere else it would work right...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a collaborative project so the other guy switched the input to be the output of another shift register and didn't tell me :(&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:07:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548829#M10710</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: SSP sending out data 7.5 bits behind, LPC1114</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548830#M10711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu May 12 19:45:45 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, always blame the hardware guys....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:07:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SSP-sending-out-data-7-5-bits-behind-LPC1114/m-p/548830#M10711</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:07:46Z</dc:date>
    </item>
  </channel>
</rss>

