SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By jaredj
#97923
I have two SPI button boards hooked up to an atmega164p.
Code: Select all
                        /--------\    /--------\
      |MOSI    --  MISO |        |    |        |
AVR   |MISO    --  MOSI |  b.1   |E  =|  b.0   |
      | SCK    --  SCK  |        |E  =|        |
      |  CS    --  CS   |        |    |        |
                        \--------/    \--------/


I've successfully convinced both of them that they're in a two-board system (i.e. LED 1 lights up at startup). I can send signals for the lights and make either or both boards light up. I've numbered them in the illustration above according to which frame of data they respond to.

I found that when I pulled CS low in between frames like the data sheet says, it didn't work. When I kept CS high for the duration of both boards' frames of data, it lit up properly, so that's what I'm doing.

Now I'm trying to get button feedback and failing.

I've soldered 2-pin headers on the Input and Output of both boards, and I've tried both running a wire from b.0 output to b.1 input, and the other way around. No dice. I've tried taking the output from the MOSI of b.0 and instead from the MOSI of b.1, still doesn't work. The datasheet seems to contradict itself. Can anyone straighten me out?

* *

On the datasheet contradicting itself, here's what it says:
The red line illustrates the feedback wire. This must be added by the user, and is required for button status feedback. To add this wire to your system, simply solder a wire from the OUTPUT 2 pin header of the last board in your system, to the INPUT 2 pin header of the first board in your system. The last board of your system is the one that receives an input from another board, but doesn't send an output; while the first board in the system is that one that outputs data to another board but doesn't receive an input. If a feedback wire is not connected to the system you will not receive the button status of the system.
In the picture (which I can't duplicate here), the wire is yellow not red, and it looks to be going from the (2-pin) INPUT of the USB button pad (board #2, highest numbered is the last board, right?) to the (2-pin) OUTPUT of board #0 (first board). The last board in the picture (#2) is the one which has a board connected to its (7-pin) Output header, but none connected to its (7-pin) Input header.
By rrpilot
#97967
The only thing i'm seeing right now is you have your SPI signals reversed. At least they are on your diagram. MISO should be connected to MISO and MOSI should be connected to MOSI.

Have you had any success with just a single board? If not, I would start there and work towards a multi-board setup.

I'm not really sure on your last statement, I took a look at the datasheet but I almost need to have one of the boards in my hands to see for sure.
By jaredj
#97969
The only thing i'm seeing right now is you have your SPI signals reversed. At least they are on your diagram. MISO should be connected to MISO and MOSI should be connected to MOSI.
That was the first wrinkle I had to figure out. Took me darn near three weeks. I didn't mention it because I thought everyone else must have seen it immediately: Page 2, Table 2 of the datasheet lists MISO as an input signal, alongside SCK and CS; and later on it says, "In order to pass the set of data, an external device must be used to control the SCK, CS and MISO signals." Right before going on to point out everything else that's backwards: bring CS high to talk to the board, not low (it's usually called /CS or /SS); and SCK is active low, not active high. (On my Atmega164p, that meant I had to turn on both the CPOL and CPHA bits of the SPI control register.)
Have you had any success with just a single board? If not, I would start there and work towards a multi-board setup.
Yeap, I got the single-board setup to work, with buttons, before embarking on the two-board setup. That's how I figured out all of the above.
By jaredj
#97975
I looked at the schematic for the SPI button pad. One of the two-pin headers connects to M_MISO and the other to MOSI. I couldn't find any other reference than the two-pin header to M_MISO in the SPI schematic. Then I looked at the USB schematic, and saw that M_MISO connects to a pin on the master programming header and to MISO on the additional ATmega48 used to talk to the USB interface chip. A close look at my SPI board (it has blank spots for the USB stuff) appears to indicate that the Input two-pin header is the one that connects to M_MISO.

It appears, then, that those two-pin headers only matter when there is a USB button board in the mix.
By ryowens84
#98002
You could try attaching the feedback wire from the output pin to the MISO pin labeled on the sides of the board, rather than the 'input' pin. The last poster is correct; the pin labeled 'input' only works on a USB button pad controller, not the SPI one.
By jaredj
#98123
ryowens84 wrote:You could try attaching the feedback wire from the output pin to the MISO pin labeled on the sides of the board, rather than the 'input' pin.
Don't the 7-pin headers already accomplish that? MISO and MOSI are already among the things they connect... oh. So I connected the output pin of board 0 (the board I don't have wires running to) to MISO of board 1, and now I get random colors on board 1. It seemed more promising when I attached MOSI of board 0 to MISO of my microcontroller: random things didn't happen. But I also didn't seem to get any feedback? Back to the breadboard...
The last poster is correct; the pin labeled 'input' only works on a USB button pad controller, not the SPI one.
Thanks, that's good to be sure of
By jaredj
#98376
Success!!
Code: Select all
              /------------------------------------------\
              |          /--------\    /--------\        |
      |MOSI - | --  MISO |        |    |        |        |
AVR   |MISO --/          |  b.1   |E  =|  b.0   | MOSI --/
      | SCK ------  SCK  |        |E  =|        |
      |  CS ------  CS   |        |    |        |
                         \--------/    \--------/

(My actual setup has SCK and CS running to board 0 as well, but I don't think this matters much.)

Again, I'm not pulling CS low between the frames for the two boards.
By Adilson
#109487
jaredj wrote:Success!!
Code: Select all
              /------------------------------------------\
              |          /--------\    /--------\        |
      |MOSI - | --  MISO |        |    |        |        |
AVR   |MISO --/          |  b.1   |E  =|  b.0   | MOSI --/
      | SCK ------  SCK  |        |E  =|        |
      |  CS ------  CS   |        |    |        |
                         \--------/    \--------/

(My actual setup has SCK and CS running to board 0 as well, but I don't think this matters much.)

Again, I'm not pulling CS low between the frames for the two boards.
Hi

Do you mind sending the code you used? I am trying for days make this pad work with a arduino pro unsuccessfully. Thanks.