Good learning resources for using I2C SRAM (I'm using a Bus Pirate) for a noob? - Page 1
Forum section: electronics / general

author: TERRA Operative
author_rank: Super Contributor
timestamp: May 26, 2021, 03:34:16 pm
content: 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!

author: ledtester
author_rank: Super Contributor
timestamp: May 26, 2021, 05:06:36 pm
content: 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.htmlPost 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.

author: TERRA Operative
author_rank: Super Contributor
timestamp: May 27, 2021, 12:07:18 am
content: 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.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 27, 2021, 12:32:04 am
content: 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 pirateThere 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.

author: TERRA Operative
author_rank: Super Contributor
timestamp: May 27, 2021, 02:06:36 am
content: 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'..

author: ledtester
author_rank: Super Contributor
timestamp: May 27, 2021, 04:30:11 am
content: 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: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:[ 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:[ 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.

author: TERRA Operative
author_rank: Super Contributor
timestamp: May 27, 2021, 11:45:39 am
content: Quote from: ledtester on May 27, 2021, 04:30:11 amI 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.Quote from: ledtester on May 27, 2021, 04:30:11 amThat 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!Quote from: ledtester on May 27, 2021, 04:30:11 amSo that last one, we are writing 0x12 in position 0, 0x34 in position 1, and 0x56 in position 2, right?Ithinkthis is starting to make sense......I'll have a go at it tonight and let you know what happens.Thanks!

author: TERRA Operative
author_rank: Super Contributor
timestamp: May 27, 2021, 03:59:32 pm
content: Good news! I am now sending the right commands and can read and write to the RAM!Thanks ledtester.Next step, write the functions into my batch script to automate it all...