{"id":2766,"date":"2017-02-13T00:00:57","date_gmt":"2017-02-13T08:00:57","guid":{"rendered":"http:\/\/192.168.3.4\/?p=2766"},"modified":"2018-01-09T06:51:28","modified_gmt":"2018-01-09T14:51:28","slug":"spi-vs-spi-serial-peripheral-interface","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=2766","title":{"rendered":"SPI vs SPI &#8211; Serial Peripheral Interface"},"content":{"rendered":"<p>The UART serial communication method discussed in my last post showed a limitation of scale.\u00a0 Asynchronous serial data should only be point to point.\u00a0 If many devices are required, the complexity of design and cost increase.<\/p>\n<p>The Serial Peripheral Interface, or SPI protocol, is a method to reduce the complexity and costs of scaling.\u00a0 In contrast to UART, SPI does not require complex bridgeheads.\u00a0 Receiving devices need nothing more than a shift register to operate.<\/p>\n<p>Without going into too much detail about shift registers, they simply take serial data and assemble it into a parallel data.\u00a0 There is plenty of more information available about shift registers.<\/p>\n<p><iframe loading=\"lazy\" title=\"How Shift Registers Work!\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/6fVbJbNPrEU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>Another difference that makes SPI unique from UART is it uses a channel to transmit an oscillating digital signal.\u00a0 This is a clock signal and it&#8217;s used as a reference by the receiving device.\u00a0 When a receiving device detects changes of highs and lows on its data port, it references the clock signal when to determine if the data is a high or low state.\u00a0 The clock channel is often refereed to as CLK or SCK.\u00a0 It does require an additional channel, but the clock frequency is adjustable and only needs to be generated from one device, the master.<\/p>\n<p>Since SPI isn&#8217;t confined to point to point links, devices will come in two classes, either Master or Slave.\u00a0 Like UART, data can only travel in one direction.\u00a0 The sending master device uses one channel to the receiving slave device.\u00a0 The slave then replies back to the master using another channel.\u00a0 These channels are referred to MOSI (Master Out Slave In) and MISO (Master In Slave Out).<\/p>\n<p>The number of slave devices is determined by another communications channel called the Slave Select, mostly called SS.\u00a0 The master typically has a unique SS channel to each slave.\u00a0 When the master needs to link to a slave, it changes the state of the SS channel and that slave device activates.\u00a0 The only limit on the number of slaves a master can communicate with is dependent on the number of SS channels available.\u00a0 Another device can be used to increase the limitation of a master&#8217;s available SS channels, this is called a line decoder.<\/p>\n<p><iframe loading=\"lazy\" title=\"Experiments 2.6: Logic Gates -  3 Line to 8 Line Decoder Example\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/o7XKXnxxUKk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>Some instances of SPI support daisy chaining slaves to the master.\u00a0 This typically is found in LED displays that act as data relays from the master.\u00a0 The master controller activates a single SS channel to all devices.\u00a0 This activates all the slave devices to expect data.\u00a0 Then the master sends its data to the first slave through the MOSI port.\u00a0 The first slave then forwards data to the next slave with the first slave&#8217;s MISO port and the second slave&#8217;s MOSI port.\u00a0 This process continues until the last slave&#8217;s MISO port links back to the master.<\/p>\n<p><iframe loading=\"lazy\" title=\"Modified Planet Bike Blinky with Shift Register\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/CUc_xuuVmIw?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>I had used SPI to control several LEDs contained in a tail light on my bike.\u00a0 The project let me turn on the tail light and increase its brightness when the breaks were used.\u00a0 It also let me use the tail light as a turn signal.<\/p>\n<p>At any point, this is pretty much what SPI is and a good foundation for understanding how it works.\u00a0 We&#8217;ll be relying on this for more advanced topics later.\u00a0 Thank you once again and I look forward to having you back.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The UART serial communication method discussed in my last post showed a limitation of scale.\u00a0 Asynchronous serial data should only be point to point.\u00a0 If many devices are required, the complexity of design and cost increase. The Serial Peripheral Interface, or SPI protocol, is a method to reduce the complexity and costs of scaling.\u00a0 In contrast to UART, SPI does not require complex bridgeheads.\u00a0 Receiving devices need nothing more than a shift register to operate. Without going into too much&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=2766\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6,3,8],"tags":[],"class_list":["post-2766","post","type-post","status-publish","format-standard","hentry","category-arduino","category-raspberry-pi","category-rd","category-xbee"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2766"}],"version-history":[{"count":2,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2766\/revisions"}],"predecessor-version":[{"id":2776,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2766\/revisions\/2776"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}