element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs Talk SPI to EEPROM with Hercules Launchpad - part 3: Testing SPI Protocol with Bus Pirate
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 11 May 2015 4:33 PM Date Created
  • Views 728 views
  • Likes 2 likes
  • Comments 1 comment
  • hercules_launchpad
  • microchip
  • EEPROM
  • spi
  • bus_pirate
  • texas_instruments
  • serial
  • protocol
Related
Recommended

Talk SPI to EEPROM with Hercules Launchpad - part 3: Testing SPI Protocol with Bus Pirate

Jan Cumps
Jan Cumps
11 May 2015

My Peruvian mate martinvalencia and I purchased a set of 25LC256 SPI serial EEPROM chips.

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.
This time it's about testing the 25LCXX SPI read and write protocol with a Bus Pirate 4.

Feel free to jump all over us while we're doing things the wrong way.

 

image

 

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

 

image

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


image

That's easy, we only have to enable CS, write 0x06, and disable CS.

In the Bus Pirate language, that translates to:

 

[0x06]

 

The Write a few bytes sequence

 

image

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.

image

 

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

 

image

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.

image

 

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]

 

image

 

 

And here is the capture of my protocol analyzer:

 

image

 

Now that I'm able to talk to the chip, I can transfer my work to the Hercules.

 

 

Related posts
part 1: from Zero to Hero
part 2: Circuit and Test Bed
part 3: this post
part 4: First Trial on the RM46
  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +1
    As you discovered, the timing of device access is critical for some devices. Most memory systems use a constant clock and synchronous logic to make access under controlled circumstances. In the early days…
  • DAB
    DAB over 8 years ago

    As you discovered, the timing of device access is critical for some devices.

     

    Most memory systems use a constant clock and synchronous logic to make access under controlled circumstances.

     

    In the early days, we needed memory control chips to make sure that the commands were in sync with memory access and refresh cycles.

     

    Good post

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube