<?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>LPCXpresso IDEのトピックRe: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539704#M6609</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by capiman on Fri Nov 15 22:39:59 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello Rich,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sorry, i don't know AT25040, but some general points:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- When you write one byte on SPI, you get automatically one byte on SPI. This is written to FIFO and remains there when you don't read it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; You are writing 3 bytes (i assume you have configured 8 byte transfers), then reading 1 byte. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; The byte you are reading is the answer on the first byte written. Is this what you want?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Or do you perhaps need a dummy read after each write action?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Are you sure the write operation (where you set 0xAA to location 0) was successful? Perhaps there is a 0x00 at this place and read is working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Have you checked the SPI lines signals with some probe (logic analyzer, scope, TTL pen)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- This is perhaps dangerous (in term of you change something and forget to change both places):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) == 0x10);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Perhaps use the following instead (is perhaps even faster to execute)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) != 0x00);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Martin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:16:38 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:16:38Z</dc:date>
    <item>
      <title>SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539703#M6608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by richas on Fri Nov 15 13:44:01 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am having some issue with an AT25040 SPI EEPROM using the SSP interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am writing 0xAA to location 0.&amp;nbsp; I read it using this code:&amp;nbsp; &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;volatile uint8_t testVal = 0;

LPC_GPIO1-&amp;gt;FIOCLR |= (1 &amp;lt;&amp;lt; 22);//assert CE
LPC_SSP0-&amp;gt;DR = (((0x08) &amp;amp; adr) | 0x03);
while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) == 0x10);
LPC_SSP0-&amp;gt;DR = adr;
while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) == 0x10);
LPC_SSP0-&amp;gt;DR = 0x00;
while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) == 0x10);&amp;nbsp;&amp;nbsp; //LPCxpresso register watch show 0XAA in the DR here&amp;nbsp; (Mouse over of the DR shows zero!)
testVal = LPC_SSP0-&amp;gt;DR;
while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) == 0x10);
LPC_GPIO1-&amp;gt;FIOSET |= (1 &amp;lt;&amp;lt; 22);//deassert CE

return(testVal);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As I step through it, watching the SSP registers in LPCxpresso, I see the DR get loaded with 0xAA as descibed in the comment in the code.&amp;nbsp; Mouse over shows zero.&amp;nbsp; TestVAl gets loaded with 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539703#M6608</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539704#M6609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by capiman on Fri Nov 15 22:39:59 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello Rich,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sorry, i don't know AT25040, but some general points:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- When you write one byte on SPI, you get automatically one byte on SPI. This is written to FIFO and remains there when you don't read it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; You are writing 3 bytes (i assume you have configured 8 byte transfers), then reading 1 byte. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; The byte you are reading is the answer on the first byte written. Is this what you want?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Or do you perhaps need a dummy read after each write action?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Are you sure the write operation (where you set 0xAA to location 0) was successful? Perhaps there is a 0x00 at this place and read is working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Have you checked the SPI lines signals with some probe (logic analyzer, scope, TTL pen)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- This is perhaps dangerous (in term of you change something and forget to change both places):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) == 0x10);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Perhaps use the following instead (is perhaps even faster to execute)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; while ((LPC_SSP0-&amp;gt;SR &amp;amp; 0x10) != 0x00);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Martin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539704#M6609</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539705#M6610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by richas on Mon Nov 18 12:25:25 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Martin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have verfied with a scope that I am receiving on MISO the 0xAA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am watching the RNE (RX Buf Not empty) bit in the status register.&amp;nbsp; It is not set until the last (dummy) write to the DR.&amp;nbsp; It is then set.&amp;nbsp; The debugger&amp;nbsp; SSP0 peripheral view show the DR containing 0xAA.&amp;nbsp; When I read the DR the RNE bit is cleared, the DR shows&amp;nbsp; 0x00, but the variable into which I read the DR is also 0x00;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How deep is the FIFO, do I need to do repeated read to get the last entry, it reads out the least recent?&amp;nbsp; Is the FIFO empty if the RNE bit is cleared?&amp;nbsp; The manual is lacking detail....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539705#M6610</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539706#M6611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by capiman on Mon Nov 18 12:35:56 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Rich,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;could it be that you have bytes left from previous SPI accesses (write action)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to read the FIFO (BTW: 8 bytes for RX and 8 bytes for TX with 8 bit frame length) till it is empty before your read request.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I usually write 1 byte, check if it sent (bit 0 in SR), check if answer was received (bit 2 in SR) and read 1 byte.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Martin&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539706#M6611</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539707#M6612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by richas on Mon Nov 18 16:35:49 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Martin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am doing multiple reads before the read procedure to clear the fifo, although the RNE bit is cleared.&amp;nbsp; I added code to read the DR after each DR write.&amp;nbsp; I see the 0xAA in the DR after the dummy write, the RNE bit also gets set at this point.&amp;nbsp; As soon as I read the DR the DR contains zero, but my read also returns zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Speaking of dummies, this has got to be something dumb I am doing (or not doing).&amp;nbsp; It is always something dumb....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539707#M6612</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539708#M6613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by capiman on Mon Nov 18 22:30:03 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Get a logic analyzer (with SPI decoding). It will save you a lot of time...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539708#M6613</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: SPI EEPROM using SSP ( LPC1768, lpcxpresso)</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539709#M6614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by richas on Tue Nov 19 11:27:55 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I stared over.&amp;nbsp; I rewrote the routine.&amp;nbsp; First it waits for the busy flag to be cleared, then it clears the FIFO.&amp;nbsp; I wait for the busy flag to be cleared after each transaction.&amp;nbsp; It now works perfectly.&amp;nbsp; I am not sure this is different that what I have done before, I suppose it must be as it works.&amp;nbsp; :P&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SPI-EEPROM-using-SSP-LPC1768-lpcxpresso/m-p/539709#M6614</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:41Z</dc:date>
    </item>
  </channel>
</rss>

