Connect 2 AVRs with SPI bus?

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

Hello,

I'm looking for some easy sample code to connect 2 AVRs with the hardware
SPI bus.Each of them can be master or slave and request it with SS-Line.
Does anyone have a state machine or examples etc. for such a
communication?

Best Regards,

Thomas
email: rudt@teleconnect.de

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

Hi,

Does both of them need to act as masters?
Since the slave cant initiate a SPI transfer, on common solution is to use an output from the slave to an external interrupt pin on the master. If the master gets an interrupt it does a "dummy" transfer, thus reading in the information the slave want to transmit.

...much simpler than changing the master to slave and slave to master.

This solution is very good if the "data-package" transmitted by the slave has predetermined length.
(eg. you can have the master do n dummy-writes to get inn all data from the slave)

Not excactly an answer to the mail, but something to think about :)

rgds
Arild

admin's test signature
 

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

The nice thing about 8051 is, that inter MCU communication can be controlled with the "ninth transmitted bit", as in, you can software select, who is addressed when using more than one device on a bus...

Adressinf ONE device on an SPI bus seems only to be possible by dragging down the SS line one the slave, addressed. GIven, the mcus reside on different boards, this requires additional physical connections between the boards.

Q: Is there any clever "official" method of addressing mcus on a SPI bus without using physical lines and demultiplexers connected to SS?

I understand from some mails, that you work for Atmel!?

Thanks very much

Chris

admin's test signature