?? application note - vhdl implementation of a serial peripheral interface (spi).mht
字號:
From: <由 Windows Internet Explorer 7 保存>
Subject: Application Note - VHDL Implementation of a Serial Peripheral Interface (SPI)
Date: Tue, 29 Jul 2008 18:42:33 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_0173_01C8F1AA.DD234670"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
This is a multi-part message in MIME format.
------=_NextPart_000_0173_01C8F1AA.DD234670
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/2002_w/interfacing/SPI/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Application Note - VHDL Implementation of a Serial =
Peripheral Interface (SPI)</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.5730.13" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<H1>Application Note<BR>VHDL Implementation of a Serial Peripheral =
Interface=20
(SPI)</H1><FONT size=3D+2>Authors: <A =
href=3D"mailto:akchu@ee.ualberta.ca">Andrew=20
Chu</A> and <A href=3D"mailto:ohlmann@ee.ualberta.ca">Chris =
Ohlmann</A><BR>Group:=20
The Reading Book<BR>Other Group Members: Jeff Bazinet, Reid Blumell, =
Bryce=20
Palmer</FONT>=20
<H2>Serial Peripheral Interface</H2>The Serial Peripheral Interface =
(SPI) is a=20
high speed (up to 400 Mhz) synchronous serial interface/protocol =
designed by=20
Motorola. It is a popular interface used for connecting peripherals to =
each=20
other and to microprocessors. Most literature indicates that the =
interface can=20
only be used for eight or sixteen bit block data transfers, but many =
Motorola=20
microcontrollers allow transfers of any range of blocks between two and =
sixteen=20
bits at a time. Because of the serial nature of the interface, data =
transfers of=20
more than sixteen bits at a time can be implemented easily through =
control=20
signals.=20
<P>The interface uses a 3-wire bus plus a chip/slave select line for =
each device=20
connected to the bus. The three bus lines are as follows:=20
<UL>
<LI>SCLK - the clock signal used for synchronizing data transfers. It =
is=20
generated by the bus "Master"=20
<LI>MISO - Master In Slave Out. Line used for sending data from a =
slave to the=20
master.=20
<LI>MOSI - Master Out Slave In. Line used for sending data from the =
master to=20
a slave. </LI></UL>Each device connected to the bus can be selected by =
the bus=20
master using a dedicated SS (Slave Select) line for each slave device. =
It is=20
possible to have more than one master hanging off the bus, but only one =
master=20
can be active at any given time. The implication of this configuration =
is that=20
the bus master has to have as many lines as there are devices to drive =
each of=20
the SS lines.=20
<P>When the master initiates a data transfer, the master writes a bit to =
the=20
MOSI line and reads a bit from the MISO at the same time on every cycle =
of the=20
SCLK signal. The data is transfered through a simple shift register =
transfer=20
scheme where the data is clocked into and out of devices on a first-in,=20
first-out basis. This means that every data transfer results in an =
exchange of=20
bits between the master and the slave (each device is simultaneously a=20
transmitter and a receiver), making it a full duplex serial interface. =
When a=20
device is not selected, it must tri-state (release) the output (MISO) =
line.=20
Through buffering, it would be possible to drive more than one =
receive-only=20
device, but not more than one transmit-only or receive and transmit =
device since=20
there would be a contention issue on the MISO line.=20
<P>The block diagram of this process is as follows:=20
<P><IMG=20
src=3D"http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/2002_w/in=
terfacing/SPI/masterslave.gif">=20
<P>There are four possibilities for clocking the data based on the clock =
polarity and the clock phase:=20
<P><IMG=20
src=3D"http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/2002_w/in=
terfacing/SPI/sclk.gif">=20
<P>Usually, in synchronous serial protocols, data is clocked out on one =
edge and=20
clocked in on the other edge to reduce clock skew errors.=20
<P>
<H3>Advantages of SPI</H3>
<UL>
<LI>Simple transfer scheme allows many devices to use SPI easily =
through the=20
addition of a shift register.=20
<LI>Full-Duplex communications </LI></UL>
<H3>Disadvantages of SPI</H3>
<UL>
<LI>Number of wires required is proportional to the number of devices =
on the=20
bus. </LI></UL>
<H3>Alternatives to SPI</H3>
<UL>
<LI>I2C (I-squared-C) - proprietary 2-wire bus allowing bidirectional =
simplex=20
data transfers with control signals encoded in the data stream based =
on the=20
clock designed by Philips. </LI></UL>
<H2>VHDL Implementation</H2>Layer 1 protocol implementation usually =
involves=20
implementing a PHY (Physical layer interface) and a MAC (Media Access=20
Controller). The following sample implementation follows this design =
philosophy:=20
<H3>SPI PHY</H3>Implemented as a simple shift register: <A=20
href=3D"http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/2002_w/i=
nterfacing/SPI/spi_phy.vhd">spi_phy.vhd</A>=20
<H3>SPI MAC</H3>Provides a parallel interface to a higher layer with =
appropriate=20
control signals. This controller loads the PHY with the parallel data =
and sends=20
out <I>n</I> clock pulses, where <I>n</I> corresponds to the number of =
bits in=20
the parallel data, to the PHY to clock the transfer: <A=20
href=3D"http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/2002_w/i=
nterfacing/SPI/spi_controller.vhd">spi_controller.vhd</A>=20
<P>
<H2>References</H2>
<UL>
<LI>Motorola MMC2001 Reference Manual=20
<LI>Project DEEPSEA - (Digital Exportation of an Established Protocol =
from=20
Sensing Encoded Analog): <A=20
=
href=3D"http://eewww.eng.ohio-state.edu/ie/main/current_research/SPI_Naut=
ilus_chip/">http://eewww.eng.ohio-state.edu/ie/main/current_research/SPI_=
Nautilus_chip/</A>=20
</LI></UL></BODY></HTML>
------=_NextPart_000_0173_01C8F1AA.DD234670
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/2002_w/interfacing/SPI/masterslave.gif
R0lGODlhCQLdAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQ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IFz7rnY9/8eveK8ryPMFUr3/t0177Cng//P2vgvwr
H/2aAQsJ3u8VBYQfBDMoPwj2D33eo2AFvXdBDLZPKHR52/SyQhc42dAhkcNKA+WSoRv6UCE59IjZ
/+B2lR764Yh9wMMR/dCHJToRD0104hKVOEUpMtEPWogiEo9IxT5ogYtXdOIXwYhELVDRD3gY4xnR
2MQzJnGJWnxiHJ9IRyk2MYtY1BGFCJe0wQgpBWGMoxevmEYrFvKIY1xiItG4SERWMYqC/OIg4ajI
Om7RkVgMpBMH2cZGMrKSYnxiIvuAguW5CAUy/BpX2LOrQDGQj8WLi+5sZTGhZMhr8JrLkHaVoSAO
znf9IozsdgUqXGYOlcMripCM6ala7hGYJSuMK1upR6AUM5lE6WWwmPZKaLqsMNrc1TCBAjlsDmVh
wZrlV3YYF3TuqpxBCafYBMQnAPXFL7G0ijNtRf86sLATLvzZZjVvwk1n+WZAlHrP77iCOGoyU4ew
XKhglBesZQplnPQ66HdQs9FoduWPwcrRxbzyz7cIb1cxFMo1RbOcjvpFoS69WVduKVBfVqWk+xlo
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -