Shop OBEX P1 Docs P2 Docs Learn Events
SPI protocol — Parallax Forums

SPI protocol

AleksAleks Posts: 52
edited 2008-08-07 14:54 in General Discussion
I've just been given a challenge to program a system with the Javelin Stamp to communicate with a master device using SPI protocol, but I don't have a clue where to begin. Can anyone help me understand the SPI protocol and methods of achieving this with the Javelin Stamp?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-08-07 13:52
    First get the datasheet for the device you want to control.
    You can use the CPU.shiftIn() and CPU.shiftOut() to implement
    the SPI protocol. Usually three signals are used with SPI:
    CS = chipselect, usually you pull this line low to initiate a SPI transfer.
    CLK = clock, this clocks the databits to/from the device
    DATA = data, usually data consists of bytes (8 bits) but 12 or 16 bits is also possible.
    Sometimes a 4th signal is required which determines datamode or commandmode.
    The EA DOGM displays for example use 4 signals.
    Best to write a seperate class for your device. It·is quite possible such a class
    already exists. Can't tell until you specify the device.

    regards peter
    ·
  • AleksAleks Posts: 52
    edited 2008-08-07 14:02
    Unfortunately there isn't a device I'm trying to control. What I do have is a digitally tunable filter project that I've been modifying and upgrading for the past year. An overseas company is requesting a compact form that uses SPI protocol to control the filter instead of the standard 4x4 Matrix Keypad + LCD screen or RS232 interface I've been implementing. I have no problem interfacing all the parts controlled by the Javelin Stamp, that part is quite successful (thankfully). My concern now is what I'm going to have to do in order to connect the Javelin to another uController via SPI?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-08-07 14:21
    The javelin can only act as SPI master, eg. the javelin generates the clock pulses.
    The other uController must therefore be able to operate in SPI slave mode, eg. accepting
    an incoming clock signal and synchronizing dataflow with the received clockpulses.

    regards peter
  • AleksAleks Posts: 52
    edited 2008-08-07 14:27
    But isn't it possible to program the Javelin to monitor foreign clock pulses and to take appropriate actions on high or low clock pulses?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-08-07 14:47
    Sure, but the javelin will not be able to receive highspeed clockpulses.
    My guess is the highest clockfrequency the javelin can accept is
    about 10kHz, due to the fact that the javelin must store received
    bytes in an array, and memory access is about 1000 bytes per second.

    regards peter
  • AleksAleks Posts: 52
    edited 2008-08-07 14:48
    Thank you Peter. Am I correct in assuming that my proper COA should be to scrap the Javelin Stamp for this project and upgrade to the Spin Stamp? (I'm already in possession of a couple)
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-08-07 14:54
    For the javelin or spin stamp to operate in SPI slave mode, you should
    definitely move to the spin stamp if you want high throughput.
    My guess is the spin stamp will support input clockfrequency >300kHz.

    regards peter
Sign In or Register to comment.