<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hant-TW">
	<id>https://tommy0804.ddns.net/index.php?action=history&amp;feed=atom&amp;title=Application_-_LPC1768%2C_SPI_communication</id>
	<title>Application - LPC1768, SPI communication - 修訂紀錄</title>
	<link rel="self" type="application/atom+xml" href="https://tommy0804.ddns.net/index.php?action=history&amp;feed=atom&amp;title=Application_-_LPC1768%2C_SPI_communication"/>
	<link rel="alternate" type="text/html" href="https://tommy0804.ddns.net/index.php?title=Application_-_LPC1768,_SPI_communication&amp;action=history"/>
	<updated>2026-08-21T16:32:31Z</updated>
	<subtitle>本wiki上此頁面的修訂紀錄</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://tommy0804.ddns.net/index.php?title=Application_-_LPC1768,_SPI_communication&amp;diff=510&amp;oldid=prev</id>
		<title>Tommy：​Refactor: add Category:Projects</title>
		<link rel="alternate" type="text/html" href="https://tommy0804.ddns.net/index.php?title=Application_-_LPC1768,_SPI_communication&amp;diff=510&amp;oldid=prev"/>
		<updated>2026-08-21T05:17:39Z</updated>

		<summary type="html">&lt;p&gt;Refactor: add [[Category:Projects]]&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hant-TW&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上個修訂&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年8月21日 (五) 13:17的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l74&quot;&gt;第74行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第74行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [http://www.petervis.com/Raspberry_PI/SPI_Seria, Raspberry Pi SPI]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [http://www.petervis.com/Raspberry_PI/SPI_Seria, Raspberry Pi SPI]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Projects]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tommy</name></author>
	</entry>
	<entry>
		<id>https://tommy0804.ddns.net/index.php?title=Application_-_LPC1768,_SPI_communication&amp;diff=85&amp;oldid=prev</id>
		<title>Tommy：​已建立頁面，內容為 &quot;SPI communication between RPi and LPC1768 == Hardware == RPi GPIO File:LPC1768_pinout.png|thumb|…&quot;</title>
		<link rel="alternate" type="text/html" href="https://tommy0804.ddns.net/index.php?title=Application_-_LPC1768,_SPI_communication&amp;diff=85&amp;oldid=prev"/>
		<updated>2018-08-23T02:31:45Z</updated>

		<summary type="html">&lt;p&gt;已建立頁面，內容為 &amp;quot;&lt;a href=&quot;/index.php/%E6%AA%94%E6%A1%88:PRi_SPI_LPC1768.jpg&quot; title=&quot;檔案:PRi SPI LPC1768.jpg&quot;&gt;border|350px|SPI communication between RPi and LPC1768&lt;/a&gt; == Hardware == &lt;a href=&quot;/index.php/%E6%AA%94%E6%A1%88:GPIOs.png&quot; title=&quot;檔案:GPIOs.png&quot;&gt;thumb|RPi GPIO&lt;/a&gt; File:LPC1768_pinout.png|thumb|…&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新頁面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[File:PRi_SPI_LPC1768.jpg|border|350px|SPI communication between RPi and LPC1768]]&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:GPIOs.png|thumb|RPi GPIO]]&lt;br /&gt;
[[File:LPC1768_pinout.png|thumb|NXP LPC1768 pinout]]&lt;br /&gt;
[[File:spi_timing.png|thumb|SPI timing]]&lt;br /&gt;
&amp;lt;pre width=100&amp;gt;&lt;br /&gt;
RPi2               NXP LPC1768&lt;br /&gt;
MOSI(GPIO10)  --   MOSI(p5)&lt;br /&gt;
MISO(GPIO09)  --   MISO(p6)&lt;br /&gt;
SCLK(GPIO11)  --   SCLK(p7)&lt;br /&gt;
CE0(GPIO08)   --   (p8)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
* RPi using libbcm2835&lt;br /&gt;
** gcc -o spi spi.c -lbcm2835&lt;br /&gt;
** unknown why BCM2835_SPI_MODE1 is more stable??&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;bcm2835.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
      if (!bcm2835_init())&lt;br /&gt;
        return 1;&lt;br /&gt;
&lt;br /&gt;
    bcm2835_spi_begin();&lt;br /&gt;
    bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST);      // The default&lt;br /&gt;
    bcm2835_spi_setDataMode(BCM2835_SPI_MODE1);                   // The default&lt;br /&gt;
    bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_65536); // The default&lt;br /&gt;
    bcm2835_spi_chipSelect(BCM2835_SPI_CS0);                      // The default&lt;br /&gt;
    bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW);      // the default    &lt;br /&gt;
&lt;br /&gt;
    // Send a byte to the slave and simultaneously read a byte back from the slave&lt;br /&gt;
    // If you tie MISO to MOSI, you should read back what was sent&lt;br /&gt;
    uint8_t data = bcm2835_spi_transfer(0x12);&lt;br /&gt;
    printf(&amp;quot;Read from SPI: %02X\n&amp;quot;, data);&lt;br /&gt;
&lt;br /&gt;
    bcm2835_spi_end();&lt;br /&gt;
    bcm2835_close();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*NXP LPC1768&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;mbed.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
SPISlave device(p5, p6, p7, p8); // mosi, miso, sclk, ssel&lt;br /&gt;
&lt;br /&gt;
Serial pc(USBTX, USBRX); &lt;br /&gt;
int main() {&lt;br /&gt;
	device.reply(0x00);              // Prime SPI with first reply&lt;br /&gt;
	while(1) {&lt;br /&gt;
		if(device.receive()) {&lt;br /&gt;
			int v = device.read();   // Read byte from master&lt;br /&gt;
			device.reply(v);         // Make this the next reply&lt;br /&gt;
			pc.printf(&amp;quot;reply: %02x\n&amp;quot;, v);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
* [https://developer.mbed.org/questions/1331/How-to-Delay-SPI-Slave-to-Master-Respons/, How to Delay SPI Slave to Master Response?]&lt;br /&gt;
&lt;br /&gt;
* [http://www.mathworks.com/help/supportpkg/raspberrypiio/ug/use-the-spi-interface-on-the-raspberry-pi-hardware.html, Use the Raspberry Pi SPI Interface to Connect to a Device]&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus, wiki, Serial Peripheral Interface Bus]&lt;br /&gt;
&lt;br /&gt;
* [http://www.airspayce.com/mikem/bcm2835/group__spi.html#gad623657d9513faa89d22ae1dc87eec38, libbcm2835]&lt;br /&gt;
&lt;br /&gt;
* [http://www.petervis.com/Raspberry_PI/SPI_Seria, Raspberry Pi SPI]&lt;/div&gt;</summary>
		<author><name>Tommy</name></author>
	</entry>
</feed>