SPI fail....

Well, you probably guessed that wasnt supposed to happen...(hint:I sent "Hello World!", this mess came out(actually, its diffrent everytime i send it)

So, considering SPI is LSB first, it seems like the gameduino sometimes misses the clock...

It works completely fine when doing SPI from the AVR, this only happens with SPI from Linux.

What i did:

  • install kmod-spi-custom from SPI over GPIO in OpenWrt | Randomcoderdude's blog (the ar71xx version, as thats what packages downloaded with opkg are, so im assuming its right)
  • enable the level shifters
  • insmod spi-gpio-custom bus0=1,11,27,8,0,1000,19 (frequency low on purpose, similiar results on higher frequencys)
  • echo -en "\x80\x00Hello World!" > /dev/spidev1.0

For some arcane reason, i got it working by changing the spi mode to 2, whereas both the avr code AND the gameduino documentation state its mode 0...

(new line: insmod spi-gpio-custom bus0=1,11,27,8,2,1000,19)

Hmmm... is there something in the level shifters that inverts the clock?

Actually, I don't trust the mode numbers when using SPI, as I've found some disagreements between vendors and chips as to what they think the numbers mean. I always look at the timing waveforms for the various devices (master and all slaves) to work out the settings. Doing so, I've occasionally found the situation where the master calls it mode X while the slave calls the same waveforms mode Y. It takes time to compare timing diagrams, but less time than trying to figure out why things are flaky.

In your case, with the wrong clock polarity, you're latching in the data while it is changing. No wonder the results were random.

When you're happy with the way it works, I'd love to see your SPI code.

Well, there isnt much code now, basically just some stuff in rc.local to set the driver up...
Still need to figure some stuff out...

Still need to figure some stuff out...

Like I said, when you're happy with the way it works. :wink: No hurry, but I'm sure others would also like to see the results, not just me.

Well, im going to build a little games console, im sure i will post something about it when im done.