<?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>LPC MicrocontrollersのトピックRe: LPC55S06 SPI write works, read no!</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1796474#M55241</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/21218"&gt;@MarcoGiammarini&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about first use the SPI demo under SDK?&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>Mon, 29 Jan 2024 02:15:54 GMT</pubDate>
    <dc:creator>Alice_Yang</dc:creator>
    <dc:date>2024-01-29T02:15:54Z</dc:date>
    <item>
      <title>LPC55S06 SPI write works, read no!</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1792998#M55201</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using LPC55S06 to communicate with another microcontroller by using SPI. My microcontroller is the master, the other one is the slave. The configuration is CPOL=0 and CPHA=0, and the datarate is 500kbps. The protocol is 2 byte of register address (with 1 bit that indicate read/write) and 4 byte of data.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SPI_config.png" style="width: 988px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/259423i55A1EBE6B09FB849/image-size/large?v=v2&amp;amp;px=999" role="button" title="SPI_config.png" alt="SPI_config.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I write a register no problem on my way: the data sniffed with a logic analyzer is perfect, and the slave read data well. When I try to read a register, the slave send out the data, on the logic analyzer the data is perfect, but on microcontroller the last bit will be lost.&lt;/P&gt;&lt;P&gt;In example, if the data that I see on logic analyzer is 0x00000064, on micro I read&amp;nbsp;0x00000032, and so on. The code that read&amp;nbsp; is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void writeReadRegister (DeviceHandle_t handle,
                             bool readWrite,
                             Register_t addr,
                             uint32_t* message)
{
    uint8_t txData[6];
    uint8_t rxData[6];
    uint32_t tmpMessage = *message;

    //readWrite = 1 write
    if (readWrite == 1)
    {
        memset(txData, 0, sizeof(txData));
        txData[0] = 0x01;
        txData[1] = (uint8_t)addr;
        txData[2] = (uint8_t)((tmpMessage &amp;gt;&amp;gt; 24) &amp;amp; 0x000000FF);
        txData[3] = (uint8_t)((tmpMessage &amp;gt;&amp;gt; 16) &amp;amp; 0x000000FF);
        txData[4] = (uint8_t)((tmpMessage &amp;gt;&amp;gt; &lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt;  &amp;amp; 0x000000FF);
        txData[5] = (uint8_t)(tmpMessage         &amp;amp; 0x000000FF);
    }
    //readWrite = 0 read
    else if (readWrite == 0)
    {
        memset(txData, 0, sizeof(txData));
        txData[0] = 0x00;
        txData[1] = (uint8_t)addr;
        memset(rxData, 0, sizeof(rxData));
        rxData[0] = 0x00;
        rxData[1] = (uint8_t)addr;
    }
    handle-&amp;gt;xferDefault.txData = txData;
    handle-&amp;gt;xferDefault.rxData = rxData;

    GPIO_PinWrite(handle-&amp;gt;gpioPeripheral, handle-&amp;gt;port, handle-&amp;gt;pin, 0);
    App_mDelay(1);

    SPI_MasterTransferBlocking(handle-&amp;gt;peripheralNum, &amp;amp;handle-&amp;gt;xferDefault);

    App_mDelay(1);
    GPIO_PinWrite(handle-&amp;gt;gpioPeripheral, handle-&amp;gt;port, handle-&amp;gt;pin, 1);

    if (readWrite == 0)
    {
        uint32_t temp = 0;
        temp = (((uint32_t)rxData[5])       &amp;amp; 0x000000FF) |
               (((uint32_t)rxData[4] &amp;lt;&amp;lt; &lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt;  &amp;amp; 0x0000FF00) |
               (((uint32_t)rxData[3] &amp;lt;&amp;lt; 16) &amp;amp; 0x00FF0000) |
               (((uint32_t)rxData[2] &amp;lt;&amp;lt; 24) &amp;amp; 0xFF000000);
        *message = temp;

    }
}&lt;/LI-CODE&gt;&lt;P&gt;Where is the error? I can't see!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 12:45:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1792998#M55201</guid>
      <dc:creator>MarcoGiammarini</dc:creator>
      <dc:date>2024-01-22T12:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S06 SPI write works, read no!</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1793497#M55213</link>
      <description>&lt;P&gt;Try CPHA=1&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 06:39:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1793497#M55213</guid>
      <dc:creator>al_bin</dc:creator>
      <dc:date>2024-01-23T06:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S06 SPI write works, read no!</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1796474#M55241</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/21218"&gt;@MarcoGiammarini&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about first use the SPI demo under SDK?&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>Mon, 29 Jan 2024 02:15:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1796474#M55241</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2024-01-29T02:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S06 SPI write works, read no!</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1804115#M55382</link>
      <description>&lt;P&gt;Hi, I found the problem: the slave device, an FPGA programmed by ourself, generate a wrong MISO message... so the microcontroller can't read well the data.&lt;/P&gt;&lt;P&gt;Thanks all.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 13:49:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S06-SPI-write-works-read-no/m-p/1804115#M55382</guid>
      <dc:creator>MarcoGiammarini</dc:creator>
      <dc:date>2024-02-08T13:49:04Z</dc:date>
    </item>
  </channel>
</rss>

