SPI Slave Device on ATmega64

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

I'm having a problem with initializing an SPI slave device and maintaining its proper operation. The data being returned to the master is from some front panel switches. 0xFF means no switches are down, and zero bits mean one or more switches are held down. Data from the master is destined for a display. On one of the master devices there are no apparent problems. On the other one however, the switch data that I am writing to SPDR apparently causes the WCOL bit to be set. This in turn apparently causes the SPI receiver to read 0x00 from SPDR for every successive interrupt, despite the Beagle Analyzer showing copious amounts of non-zero display data. If I force a watchdog RESET then the SPI recovers and the second master works pretty much like the first one which never seems to have the problem.

I have some questions:

1. How can I avoid the WCOL problem from occurring in the first place?
2. How can I recover from it once it does?
3. How would you initialize the SPI port, check for this condition, and correct it?

We never have time to do it right,
but we always have time to do it over

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

Sorry but it's not clear to me...is the M64 the MASTER or the SLAVE? If it's the master what are you doing with /SS? Is it an output? If not the SPI will revert to slave mode as soon as the pin goes low. (write collision error)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
Sorry but it's not clear to me...is the M64 the MASTER or the SLAVE? If it's the master what are you doing with /SS? Is it an output? If not the SPI will revert to slave mode as soon as the pin goes low. (write collision error)

Sorry for the confusion. The title says "SPI Slave Device on ATmega64". The ATmega64 is implementing a "display controller" for another board. It is the slave device. /SS is my slave select input.
There are two different Master devices that can operate with my board. With the same code in the ATmega64 Slave Device, with one of the master boards the slave device works fine and with the other master board the slave device does not work quite so well.

We never have time to do it right,
but we always have time to do it over

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

Papabravo wrote:

There are two different Master devices that can operate with my board. With the same code in the ATmega64 Slave Device, with one of the master boards the slave device works fine and with the other master board the slave device does not work quite so well.

Lt. Theodore 'Ted' Sawyer: There was an attempted mugging half a block from here tonight.
Jeff Blue: Really?
Lt. Theodore 'Ted' Sawyer: The victim got away.
Jeff Blue: Oh, good.
Lt. Theodore 'Ted' Sawyer: You don't know nothing about that?
Jeff Blue: No, I don't think so.
Lt. Theodore 'Ted' Sawyer: You match the description of the intended victim: a man with a baby stroller.
Det. Sgt. Halsey: And we got us a bag lady that says she saw the man enter this hotel.
Lt. Theodore 'Ted' Sawyer: And the desk clerk says that man was you.
Jeff Blue: Well, that certainly narrows it down, doesn't it?