Problem with SPI

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I have a system with multiple AVRs connected via radio tranceivers using SPI. I've configured one as master, and the others as slave, and have a problem with the algorithm and the SPI. the algorithm is basically this:

Master transmits byte.
If recieved byte is correct (slave polls for byte from master), slave transmits confirmation byte.
Else slave does nothing (Doesn't transmit)

However I've read that the master must initiate all data transmissions, and this is a problem since, the slave needs to recieve the byte, check if its correct, and then either transmit nothing (since multiple slaves are connected via radio transceivers), or transmit a confirmation byte - but how can it do this if the slave can't initiate a transmission?

What's the proper way to accomplish this using SPI? (The circuit is already built, so it must be SPI and no other serial interface).

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SPI is a REALLY bad fit to radio communication. SPI expects a bit input for every bit transmitted and it is synchronous, with a companion clock signal. And, it expects a "chip select". You get none of these with radios.

I would suggest something bit-banged through the SPI pins because standard SPI hardware just won't do it.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, thanks for the reply, sorry I've taken so long to reply, I've been occupied with a ton of college work.

Is there any chance you could give me an example of how to bit bang through the SPI port? e.g. how ould I trnasmit and recieve an 8-bit unsigned char?

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

all the AVR's IO pins are multi-function [with a few exceptions on some devices] as such your SPI pins, are also GPIO's. Bit-Banging is simply a matter of toggeling the states of the opins in a software controlled manner. But before you get to bit-banging, you need to decide on a protocol to use.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.