Our plan was to get them working with the Texas Instruments Hercules LaunchPad MK II.
That was back in January. And then we stalled.
Martin has restarted the exercise and I'm going to play along.
This blog is our path from Zero to Hero.
Feel free to jump all over us while we're doing things the wrong way.
SPI Protocol Prototyping with the Bus Pirate
It wasn't my initial intention to use the Bus Pirate.
But my first naive attempts to talk from Hercules to EEPROM failed.
I could create the SPI instructions with the LaunchPad, but I didn't get a reply back from the 25LC256.
It's in these cases that a Bus Pirate comes in handy. It's easy to prototype a SPI conversation from the Pirate's command prompt.
Wiring the Bus Pirate and powering the EEPROM
The wiring is easy. Just connect the correct grabber to the correct pin of the chip.
I just unplugged the patch wires of my prototype (see previous post) from the launchpad and connected them to the bus pirate.
Then I terminaled to the Bus Pirat and activated the SPI menu.
I accepted all default settengs, and took the lowest frequency (my goal was not to have a fast proto, but a working proto).
Once in the SPI menu, I activated the power supply by entering the command W.
Simulate the SPI Communication
There are three things to do:
- send write enable command
- send write command
- send read command
The extracts below are from the Microchip 25LC256 datasheet. The Bus Pirate commands are based upon this instructable, translated to the 16 bit addresses of the 25LCXXX.
The write Enable Sequence
That's easy, we only have to enable CS, write 0x06, and disable CS.
In the Bus Pirate language, that translates to:
The Write a few bytes sequence
Here we enable CS, send 0x02, two bytes as address (we take 0:0), and the sequence of bytes to write.
The action stops when we disable CS.
[0x02 0x00 0x00 0x03 0x02 0x01]
The Read a few bytes sequence
The third step is to read back the bytes we just wrote.
So we CS, then write 0x00 and the two address bytes 0x00:0x00, we retrieve the data from the EEPROM and unselect CS
[0x03 0 0 r:3]
This is what we get in the bus Pirate console:
SPI>W POWER SUPPLIES ON SPI>[0x06] /CS ENABLED WRITE: 0x06 /CS DISABLED SPI>[0x02 0x00 0x00 0x03 0x02 0x01] /CS ENABLED WRITE: 0x02 WRITE: 0x00 WRITE: 0x00 WRITE: 0x03 WRITE: 0x02 WRITE: 0x01 /CS DISABLED SPI>[0x03 0 0 r:3] /CS ENABLED WRITE: 0x03 WRITE: 0x00 WRITE: 0x00 READ: 0x03 0x02 0x01 /CS DISABLED SPI>w POWER SUPPLIES OFF
We see that it works, and that we get our data back.
A powerdown and reread confirms this:
SPI>w POWER SUPPLIES OFF SPI>W POWER SUPPLIES ON SPI>[0x03 0 0 r:3] /CS ENABLED WRITE: 0x03 WRITE: 0x00 WRITE: 0x00 READ: 0x03 0x02 0x01 /CS DISABLED
The Timing Issue
When I executed these 3 sequences in one line, the communication failed and I didn't get anything back.
That pointed to a timing issue. That's a good thing to check when something works if you run the commands one by one, but it fails if they are streamed in sequence.
It turned out that I had to put a few milliseconds between write and read (I will check the 26LCXXX datasheet later)..
This command worked, where each % represents 1 ms:
[0x06][0x02 0x00 0x00 0x03 0x02 0x01]%%%[0x03 0 0 r:3]
And here is the capture of my protocol analyzer:
Now that I'm able to talk to the chip, I can transfer my work to the Hercules.
|part 1: from Zero to Hero|
|part 2: Circuit and Test Bed|
|part 3: this post|
|part 4: First Trial on the RM46|