Best Microcontroller Projects


XML RSS
What is this?
Add to My Yahoo!
Add to My MSN
Add to Google

Home
LCD-KEYS OnePort
Digital Downloads
C Course
State Machines
Interrupt Secrets
Schematic Tool
PIC Introduction
PIC Programming
PIC Programmers
PIC Compilers
PIC Projects
Tips & Techniques
Store
My SECRET
Oscilloscopes
Contact Me
About Me
Terms of Use
Search This Site
Freebies
Articles
Problem?-Solution
MicroBlog
Books
Resource Links
Site Map
Your Projects
Video du Jour
Rant/Rave
Privacy Policy

I use and
recommend Firefox
for the best internet
browsing experience. Click below for your
free copy today:

CLICK THE IMAGE:


Note: I find it faster
and easier to use and
it has great plugins.  

It even imports all your current
browser settings!

There's no risk as your existing browser is not affected in any way - you can just choose which one to use.


Find Out How This
Site Works
Like any engineering problem with the right tools it's Easy.
CLICK HERE 

Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Find out Why social bookmarking is
Useful For You.

Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon





SPI interface tutorial.



SPI Interface or Serial Peripheral Interface bus is as you might expect a serial interface meaning data is shifted out (and in) one bit at a time.

Project Update:

"Measuring Analogue Voltages

Without An ADC"


FREE )

Warning: This project could be Removed at
any time and will NOT be available indefinitely.
To avoid disappointment get it Now.


Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access enter your
Name and Primary email Now:


Primary Email
First Name

Don't worry -- your e-mail address is totally secure.
I promise to use it only to send you MicroZine
Note: Look through the back issues for your
No-ADC method).


P.S. The newsletter also has essential information for you as well.

More Resources...
It is intended for transmission of data from a master device to/from one or more slave devices over short distances at high speeds (MHz).

It is simply based on an 8 bit shift register shifting data out on a single pin and shifting data in on another pin.

Note: some devices use more than 8 bits!

Its main use is to replace parallel interfaces so you don't have to route parallel buses around a pcb.  pic spi masterFor example you can buy an SPI 12bit ADC and instead of 12 parallel wires to read the data you only need 4 SPI connections.  Actually you may only need three as you may not need to send data to the device!

 With the SPI interface you can communicate with a device transmitting and receiving 8 bits of data at the same time and it is suited to high speed streaming data transfers.

Note: The trade off between 
usingpic spi slaveparallel interface and the SPI interface is speed e.g. if you read a parallel 12bit ADC at 200ksps then you could read the device at a 200kHz rate but if you want to get the same data rate using SPI then you need a serial speed of 200kHz x 12 = 2.4MHz.  So the actual trade off is speed and the consequential noise introduced into the circuit.

Unlike I2C there is no concept of transferring ownership of the bus i.e. changing bus master and there are no slave device addresses.  SPI is a much simpler protocol and because of this you can operate it at speeds greater than 10MHz (compared with the 3.4MHz maximum for I2C).

The best feature of SPI is that you can do full duplex data transfers (data in both directions at the same time) which you can not do with 
I2C and you can do it fast.

Note: The maximum rate for a PIC Micro using a 20MHz clock is 5MHz.

SPI Interface : Signals

SPI Interface Signals
PIC name Master Slave
SCK Serial clock output from master [SCK] Input to slave [SCK]
SDO Serial data output from master [MOSI] Input to slave [MOSI}
SDI Serial data input from slave [MISO] Output from slave [MISO]
SS Optional slave (chip) select [SS] 
Slave select [SS]

[] denotes SPI naming convention

Here is the setup for a single SPI device connection:

SPI Interface - single device
single SPI device

Note: The chip select signal SS is optional for a single device system as you could tie the SS input at the slave low if the other lines are dedicated to SPI use.


There are two ways to implement multiple slave operation:
  • Use a separate chip select for each slave device.
  • Wire all the slaves together DataOut to DataIn (daisy chain).

SIP Interface : Using chip selects

SPI Interface using separate chip selects

SPI interface with multiple chip selects

With this scheme you control each slave device using its chip select line (usually active low- red arrows show control lines).  When disabled the Data output from the slave goes into a high impedance state so it does not interfere with the currently selected slave and the data input is ignored (check datasheet).

The advantage of this scheme is that you can consider each device separately when you compare it with the daisy chain method.

SPI Interface : Daisy chaining

SPI interface with daisy chain
With this scheme all data sent by the master is shifted into all devices and all data sent from each device is shifted out to the next (shown by red dotted arrow).  For this scheme to work  you have to make sure that each slave uses the clock in the same way (see clock and data) and you have to get the right number of bits - so there is more work to do in software.

Compared to 
I2C these are very inelegant slave selection mechanisms and look like kludges to get round the fact that SPI was designed really as a simple single master to single slave protocol.  Having said that the above methods will work but for daisy chaining you will have to be careful of clock polarity and clock use as this is not defined in the SPI standard.

SPI Interface : Clock and Data

How a device reacts to clock input is undefined!!!

Data can be sampled at the rising or falling edge and data can be generated after the rising or falling edge!

This is why you can set the clock output from a master mode device in multiple ways just look at the diagram below - the first four signals are the four options you have to select the output clock.

SPI Interface PIC signals (extract from DS39582B)
PIC SPI interface signals

You match the output clock to the clock that your device requires.

Note: This is why daisy chaining may not be a good idea (or you have to think very carefully about it!).

Note: For Master or Slave mode when using PICs you need to set the TRIS direction of the SCK pin appropriately.

Problems with the SPI interface

  • The clock scheme may not be the same between devices.
  • The data length can vary from device to device.

Advantages of the SPI interface 

  • Very fast > 10Mhz.
  • Simple protocol (easy to program in software if you have no SPI hardware module).
  • Simple interface (no bidirectional pins c.f. I2C).
  • Supports full duplex data streaming.

Jump from SPI Interface to
Best-Microcontroller-Projects Home Page


Don't forget to Sign Up for your

Microcontroller Newsletter

With "Essential tips and techniques",

..."New Site Info" and more...

Including a free project :

How to drive an LCD and 12key keypad using "Only One 8 Bit Port" with no interface logic!...

(Works for any microcontroller)

This costs you : Nothing...
Just fill out the form below and you'll get full C source code and project schematic and description.



Email

Name

Then

Don't worry -- your e-mail address is totally secure.
I promise to use it only to send you MicroZine.
Google
 
  Best Microcontroller projects.