Author Topic: Good learning resources for using I2C SRAM (I'm using a Bus Pirate) for a noob?  (Read 1205 times)

0 Members and 1 Guest are viewing this topic.

Online TERRA OperativeTopic starter

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: jp
  • Voider of warranties
    • Near Far Media Youtube
I'm currently working on a project to read and write calibration data directly into the SRAM in a Tek AM503B Current Probe Amplifier using a Bus Pirate and IC clip, as the parts needed to do it the 'proper' way are no longer available.
I am a complete and utter noob at this sort of thing so I'm looking for some decent ground up info on talking to an SRAM chip over I2C.

Does anyone have any good links to info on this sort of thing that assume very little prior knowledge, or is anyone willing to teach me some stuff to get me going? My expertise in programming is primarily using solder so I have ALL the dumb questions to ask..... :)

Thanks!
Where does all this test equipment keep coming from?!?

https://www.youtube.com/NearFarMedia/
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3032
  • Country: us
I would get an Arduino and learn how to program it to talk to an I2C device.

There will be a lot more resources available to you -- i.e. examples, people, forums -- if you use an Arduino. Here, for instance, is some example code to talk to an SRAM chip:

https://arduino-related.livejournal.com/1414.html

Post your progress here, and I'm sure we can solve whatever problem you run into.

Oh, and of course buy an SRAM chip to experiment on before attempting to modify the AM503B.  :)
 

Online TERRA OperativeTopic starter

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: jp
  • Voider of warranties
    • Near Far Media Youtube
I already have the Bus Pirate and (with a big stretch of my skills) a batch file to talk to it, but no Arduino's to hand.
I just need to learn how to talk to the SRAM chip over I2C, I'm at a fundamentals level here..... :) I have it hooked up and I seem to be able to send some commands and get something in return, but not much more than that.

I'm not just out of my element here with software stuff, I'm completely off the periodic table. :D
Where does all this test equipment keep coming from?!?

https://www.youtube.com/NearFarMedia/
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3321
  • Country: nl
I haven't used a bus pirate, but frwom what I've seen you can connect to wit via a terminal emulator from your PC and then type in commands send to or read from I2C or other supported protocols.
I think it's also common to write some scripts (in for example python) to control the bus pirate

There must be a manual and even tutorials and youtube vid's which explain more details.
Is there important (battey backed up?) data in your RAM? If so, then start by playing around with your Bus pirate and some other I2C Chips untill you have a bit more experience, and even then, the first thing you should do with your I2C Ram is to read-out all data and back it up.
 

Online TERRA OperativeTopic starter

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: jp
  • Voider of warranties
    • Near Far Media Youtube
The data in the RAM is battery backed, but it is no problem to be erased etc as it was already gone because the battery was flat and leaking (I have repaired the damage). So this poking at things with the Bus Pirate is my feeble attempt to figure out how to write new calibration values.

The RAM chip is a PCF8570 (Datasheet below), and while I've been successful in sniffing the bus, using the Bus Pirate to successfully read and write to the RAM eludes me.

Most of the few guides I've seen around assume a level of knowledge that I don't have. A common thing I've seen in a lot of this sort of stuff is it's either hand holding how to connect wires to pins on a breadboard for a specific example application, or it's all assumed knowledge 'just sent these commands and bingo!' stuff. I'm in the middle so I don't need to be told about pullups and what to connect where, but I don't know enough to 'just send a few hexadecimal values to read an address'..
Where does all this test equipment keep coming from?!?

https://www.youtube.com/NearFarMedia/
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3032
  • Country: us
I don't have a Bus Pirate, but this is what I gather after reading:

http://dangerousprototypes.com/blog/bus-pirate-manual/i2c-guide/

Have a look at the example interactions at the end of that guide.

1. First determine the I2C address of the SRAM. If you use the "7bit address search" Bus Pirate macro you'll get back something like:

Code: [Select]
I2C>(1)
Searching 7bit I2C address space.
Found devices at:
0xA0(0×50W) 0xA1(0×50R)
...

0x50 is the 7-bit I2C address. You will use 0xA0 when sending a write command to the device and 0xA1 when reading.

In case the search returns multiple devices, Figure 12 of the PCF8570 datasheet shows the possible I2C addresses for the PCF8570, so that should help you figure out which one it is.

2. Issue the commands:

Code: [Select]
    [ 0xA0 0 ]
    [ 0xA1 rrrrr ]

This will first set the address pointer to address 0. The second command will read 5 bytes incrementing the address pointer for each byte.

Other read commands: [ 0xA1 r:256 ] -- read 256 bytes beginning at the current address pointer.

To write memory contents:

Code: [Select]
    [ 0xA0 0 0x12 0x34 0x56 ]

The above sets the address pointer to 0 and then writes three bytes incrementing the address pointer for each byte written. Note that write commands always specify the starting address.

Let us know how it goes.

« Last Edit: May 27, 2021, 04:33:58 am by ledtester »
 
The following users thanked this post: TERRA Operative

Online TERRA OperativeTopic starter

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: jp
  • Voider of warranties
    • Near Far Media Youtube
1. First determine the I2C address of the SRAM. If you use the "7bit address search" Bus Pirate macro you'll get back something like:

Code: [Select]
I2C>(1)
Searching 7bit I2C address space.
Found devices at:
0xA0(0×50W) 0xA1(0×50R)
...

I get a biiiiig long list of all addresses for some reason (that reason is certainly me doing something wrong), but I'll physically check the pins to find the actual address. Tracing pins and voltages is something I am able to do. :D  :-/O


2. Issue the commands:

Code: [Select]
    [ 0xA0 0 ]
    [ 0xA1 rrrrr ]

This will first set the address pointer to address 0. The second command will read 5 bytes incrementing the address pointer for each byte.

That return to 0 command is looking like the ticket, I kept getting different results when reading from the RAM, I didn't realise that setting the pointer to 0 was needed!


To write memory contents:

Code: [Select]
    [ 0xA0 0 0x12 0x34 0x56 ]

The above sets the address pointer to 0 and then writes three bytes incrementing the address pointer for each byte written. Note that write commands always specify the starting address.


So that last one, we are writing 0x12 in position 0, 0x34 in position 1, and 0x56 in position 2, right?


I think this is starting to make sense......
I'll have a go at it tonight and let you know what happens.  :-BROKE :) Thanks!
Where does all this test equipment keep coming from?!?

https://www.youtube.com/NearFarMedia/
 

Online TERRA OperativeTopic starter

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: jp
  • Voider of warranties
    • Near Far Media Youtube
Good news! I am now sending the right commands and can read and write to the RAM! :D Thanks ledtester. :)

Next step, write the functions into my batch script to automate it all...  |O
« Last Edit: May 27, 2021, 04:03:52 pm by TERRA Operative »
Where does all this test equipment keep coming from?!?

https://www.youtube.com/NearFarMedia/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf