<?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: SPI transfer between LPC54608 and Raspberry Pi</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822041#M32905</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is that you&amp;nbsp;need to make sure the clock mode (&lt;SPAN style="color: #222222; background-color: #ffffff; font-size: 16px;"&gt;Clock polarity (CPOL) and clock phase (CPHA)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;) are set up the same on both, master and slave.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 May 2019 17:13:21 GMT</pubDate>
    <dc:creator>Ray_V</dc:creator>
    <dc:date>2019-05-16T17:13:21Z</dc:date>
    <item>
      <title>SPI transfer between LPC54608 and Raspberry Pi</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822039#M32903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a LPC54608 (on a OM13092 demo board) and Raspberry Pi 3 Model B+.&lt;/P&gt;&lt;P&gt;I am trying to transfer data via SPI using the R. Pi as the SPI master and the LPC54608 as the SPI slave, but I don't manage to make it work.&lt;/P&gt;&lt;P&gt;I am using the example code "lpcxpresso54608_driver_example_spi_interrupt_b2b_slave" from the MUCXpresso SDK on the LPC54608, and the SPI example from the "bcm2835.h" library on the R. Pi that I modified a bit to match the code uploaded on the LPC54608.&lt;/P&gt;&lt;P&gt;Here is the code I am using the R Pi:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;// spi.c&lt;BR /&gt;//&lt;BR /&gt;// Example program for bcm2835 library&lt;BR /&gt;// Shows how to interface with SPI to transfer a byte to and from an SPI device&lt;BR /&gt;//&lt;BR /&gt;// After installing bcm2835, you can build this&lt;BR /&gt;// with something like:&lt;BR /&gt;// gcc -o spi spi.c -l bcm2835&lt;BR /&gt;// sudo ./spi&lt;BR /&gt;//&lt;BR /&gt;// Or you can test it before installing with:&lt;BR /&gt;// gcc -o spi -I ../../src ../../src/bcm2835.c spi.c&lt;BR /&gt;// sudo ./spi&lt;BR /&gt;//&lt;BR /&gt;// Author: Mike McCauley&lt;BR /&gt;// Copyright (C) 2012 Mike McCauley&lt;BR /&gt;// $Id: RF22.h,v 1.21 2012/05/30 01:51:25 mikem Exp $&lt;BR /&gt;#include &amp;lt;bcm2835.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;int main(int argc, char **argv)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;// If you call this, it will not actually access the GPIO&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Use for testing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// bcm2835_set_debug(1);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if (!bcm2835_init())&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("bcm2835_init failed. Are you running as root??\n");&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 1;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if (!bcm2835_spi_begin())&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("bcm2835_spi_begin failed. Are you running as root??\n");&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 1;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); // The default&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); // The default&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_128); // The default&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bcm2835_spi_chipSelect(BCM2835_SPI_CS0); // The default&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); // the default&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int BUFFER_SIZE = 64;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;char buffer[BUFFER_SIZE];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for (int i = 0; i &amp;lt; BUFFER_SIZE ; i++) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;buffer[i] = bcm2835_spi_transfer(i);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for (int j = 0; j &amp;lt; BUFFER_SIZE; j++) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("%d i = %d\n", buffer[j], j);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;On the LPC54608 part I tried to let the code untouched (I attached this source code), then I replaced the line 138:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;SPI_EnableInterrupts(EXAMPLE_SPI_SLAVE, kSPI_RxLvlIrq | kSPI_TxLvlIrq);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;by :&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;SPI_EnableInterrupts(EXAMPLE_SPI_SLAVE, kSPI_RxLvlIrq);&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to only get interrupt only when the SPI receive buffer is filled.&lt;/P&gt;&lt;P&gt;I also tried to replace this line by:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;EXAMPLE_SPI_SLAVE-&amp;gt;INTENSET = 0x10;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to get an interrupt each time the Slave Select line is asserted.&lt;/P&gt;&lt;P&gt;Using the original code, or a modified one&amp;nbsp; (with the modifications mentioned above), the data transferred between the 2 uP are not the one expected: I got random data on both side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I look with an oscilloscope to the 4 lines, everything seems to be normal on CS, SCLK AND MOSI lines: the slave select is asserted, then a clock is generated an on the SCLK line and there is a data transfer on MOSI line (which correspond to what it the actual data should be). But the data send to R.Pi by the LPC54608 on the MISO lines do not correspond to the one the Tx Buffer is supposed to be filled with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Has anyone an idea from where I am doing wrong, or has done something similar, and could provide an example code ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Nathan Sowie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:43:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822039#M32903</guid>
      <dc:creator>nathansowie</dc:creator>
      <dc:date>2018-07-17T13:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: SPI transfer between LPC54608 and Raspberry Pi</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822040#M32904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can try to debug first the code in the LPC, doing some&amp;nbsp; loop test, if you can share the images of the oscilloscope, would be great to see if the master or the slave it is producing the issue. Sometimes the signal seems ok, but the polarity or the phase are wrongly setup.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps for your design!&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sol&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2018 17:05:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822040#M32904</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2018-07-30T17:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: SPI transfer between LPC54608 and Raspberry Pi</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822041#M32905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is that you&amp;nbsp;need to make sure the clock mode (&lt;SPAN style="color: #222222; background-color: #ffffff; font-size: 16px;"&gt;Clock polarity (CPOL) and clock phase (CPHA)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;) are set up the same on both, master and slave.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2019 17:13:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-transfer-between-LPC54608-and-Raspberry-Pi/m-p/822041#M32905</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2019-05-16T17:13:21Z</dc:date>
    </item>
  </channel>
</rss>

