How to communicate with unknown I2C device?
sccoupe
Posts: 118
I am trying to figure out how to communicate via I2C with a video converter. This converter resets all of the screen position settings each time its powered down, seemingly by design. The datasheet shows that it has an I2C bus that isn't attached to anything in the box that I'm working on. The idea is to connect a prop to the bus to see if I can read all of the addresses. Then make one adjustment, say move the screen to the left one pixel using the menu buttons on the box, and then read all of the addresses again to see which one changed. This should allow me to then save just that value in the prop and write it back on power up. Pin 56 is pulled high so I guess 0x6A and 0x6B should be used for the slave address. What i'm not sure about is what should be started with as clock speed and what are the best assumptions for addresses? Just start at address 0x00 and go up from there? What is the best I2C object for this task? This would seem pretty easy i guess if it were just a known SD Card or something, but is perhaps tricky given an unknown device. Is any of this even possible without any more information on the protocol or a lost cause without the proper documentation? Thoughts? Ideas?
uP Serial Bus Interface
SCL 59 I IIC bus clocking.
SDA 60 IO IIC bus address/data bus.
ADDR_SEL_FREEZE 56 I Slave address selection.
ADDR_SEL=1: 0x6A for write, 0x6B for read.
ADDR_SEL=0: 0x4A for write, 0x4B for read.
Freeze when hardware mode (falling edge triggerand pull-up externally)
Regards.
uP Serial Bus Interface
SCL 59 I IIC bus clocking.
SDA 60 IO IIC bus address/data bus.
ADDR_SEL_FREEZE 56 I Slave address selection.
ADDR_SEL=1: 0x6A for write, 0x6B for read.
ADDR_SEL=0: 0x4A for write, 0x4B for read.
Freeze when hardware mode (falling edge triggerand pull-up externally)
Regards.
Comments
It sounds like you want to listen in on the I2C bus while you induce commands on another bus. This won't do anything: you won't hear anything on the I2C bus.
Why not look up the video converter datasheet?
Yes, the slave address seems to be 6A and 6B which fits a standard 7 bit address. There is currently no I2C traffic because there is only the video converter at the moment with nothing hooked up the the I2C pins. I want to attach a master (prop) and start talking to the converter to figure out what the register addresses are. I have the data sheet, but it is limited. The only mention of I2C is what you see above. The company that manufactures the chip and the company that makes the device are in China and have been contacted multiple times via email with no response.
Often a register will have multiple bits assigned to some function with other bits assigned to a different function. So you not only need to figure out what the various registers do, you need to figure out what each bit within the register does. IMO, this video converter would have to be capable of some amazing things in order to make it worth your time to figure this out from scratch.
Here is the link to the conveter box that is sold everywhere for as little as 10 bucks.
http://www.lenkeng.net/YPbPrzhuanVGA/lenkeng67.html
Here is the link to the datasheet for the converter chip used in this device.
http://wenku.baidu.com/view/88627b87bceb19e8b8f6bab0.html
Its not that it does anything spectacular. Its that it does everything that I need it to do EXCEPT save the screen adjustments on shutdown and does it real cheap. Its possible that I dont need to know what each bit does, just what registers change when I move the screen left or right for instance. Those are the registers that I need to poll and save for re-writing at boot up. This shouldnt bee too difficult unless these registers are changing constantly during normal operation. So in theory, take a snapshot of all of the registers that will answer a read call, move the screen to the left, take another snapshot to see which register changed. Now I would know that that register stores left to right screen position. Now do it again for up and down, then again for stretch vertical, and once again for stretch horizontal and I'm all done......In theory. Is this a good high level theory or are there wrenches waiting to be thrown into the gears?
I understand better what you want to do. Thanks.
So do you make these screen adjustments with the buttons on the front of the device? What about simulating button presses by having the Propeller trip relays which are connected internally to the buttons. Have the Prop remember what settings you want and have it automatically "press the buttons" needed to get these settings.
A better idea would be to snoop on the I2C traffic between the converter box and I2C device it uses as you adjust the screen. You could then have the Propeller send these same I2C commands to make the desired adjustments.
Correct, the better idea would be to use I2C. However, there is no snooping to do, because the I2C pins are not connected to anything in this box. Its just a feature on the chip that isnt utilized by this particular product. So, I need to setup a master I2C device to connect to these unused I2C pins on the chip and read/write these unknown registers as needed.
Great idea.
If the register content is examined before the screen settings are changed, and after the changes have been made, then this information could be used to set the registers to the desired settings in the future.
Another thought I'm having is that there is an xreset pin that sets all register values to default according to the data sheet. This pin is connected to a transistor presumably for switching. Perhaps the chip is actually saving the changes but being reset on powerup by design to auto detect resolution or something. Cutting this trace should answer this and maybe save some this work, but at this point I2C investigation needs to be done just because.
ADDR_SEL=1: 0x6A for write, 0x6B for read. Becomes device ID $35
ADDR_SEL=0: 0x4A for write, 0x4B for read. Becomes device ID $25
Obviously if you could interactively talk with the chip it would so very easy, you could examine contents, write contents, write one-liners etc. This is what I do all the time with Tachyon Forth and then I build named methods such as CHAN for instance so that if I can just type "3 CHAN" to switch the channel without having to worry any further. Tachyon already has all the utilities built in to the scan the bus and dump contents etc.
Are you sure the i2c can reflect, and set, the operations, that the buttons control ?
If you really want to use i2c, can you find a variant product that does connect the i2c, so you can at least get some working traffic to decode ?
Not many ASICS have power off storage inbuilt, as that costs a lot more to fab.
If you just want to emulate a config setup, it may be smarter to simply record/playback on the buttons.
Experiment with the delay needed for first press after POR and at what rate you can 'press' on playback
I mean, does it use the I2C bus to receive commands from an MCU, or simply to store configuration data off-chip, to be read back in on startup?
Some of these devices don't truly power down, but rather enter a low-power standby mode- might be another consideration.
Just grab one of the Tachyon binaries which also has the word .I2CBUS in there which will list out devices and their basic contents. Connect serial terminal at 230400 baud.
.I2CBUS
Fast Device at 00A0 00 00 00 00 00 00 00 00
Fast Device at 00A2 52 4D 82 C4 01 07 43 4F
Fast Device at 00A6 00 3B 58 08 6F 4E 10 00 ok
Thanks Peter. This was up and working pretty quickly and easily. It seems that the wiring connections may be good. Perhaps you can take a look at the results. The first .I2CBUS was run without anything hooked up. Presumably 0xA0 is the EEPROM on the Prop board. The second and third .I2CBUS runs were with the video chip hooked up. It seems like a lot of noise or something causing all of this or is this a normal thing? A0 is not in either of the other two calls...
Probably be a bit easier to read if you turned off echo and extra line feed or if you can't then just use TeraTerm. Anyway, it looks like there is activity on those lines I guess. You could try pasting in this next line and then invoking it by name "MON" which will simply spit out a digit representing the I2C lines, 3 = idle, 2 = clock low data high, 1 = clock high data low, 0 = clock low data low.
pub MON BEGIN CR #64 FOR P@ #28 SHR 3 AND . NEXT ESC? UNTIL ;
You can terminate the monitoring by hitting the escape key.
Your device is in the same address range as my I/O expander, which is where I first encountered that problem.
That might also explain my poller finding something on every address. Those pullups are entirely too large; they should be somewhere in the 4.7K to 10K range. The poller even stated that it didn't detect a pullup on SDA, which means it was using a driven-output version. Again, the same issue as with the Prop bootloader trying to force a clock high that the slave is holding low.
Yes, right now booting from EEPROM using your I2C code. Attached to pins 8(SCL) and 9(SDA) with nothing else attached to those pins, save the pullup resistors.
While using Forth, I had to use pins 28 and 29 because I didnt know how to change them. OBEX is back up now so i'm trying some of your stuff out.
How do you know those lines are I2C? You must have some information on them and anyway if it's I2C there might already be another micro in there that's talking to it. Either way you should see some break in the listing. Just in case here's one that does a quick capture to a buffer then dumps it, a FF just means nothing is happening.
#1024 BYTES i2cbuf
pub MON BEGIN CR i2cbuf #1024 ADO P@ #24 SHR I C! LOOP i2cbuf #1024 DUMP ESC? UNTIL ;
You can use other port pins for I2C bus, if they are for instance P24 = SDA and P25 = SCL just type:
#P24 #P25 I2CPINS
Then try .I2CBUS
The datasheet (http://wenku.baidu.com/view/88627b87bceb19e8b8f6bab0.html) says they are IIC pins. There is no other micro on the converter board and these two pins are currently unused. I wish to make use of them.
You may need to add pullup resistors then as the datasheet seems to indicate that there are none on the chip and that may be the case with pin 56 (ADDR_SEL_FREEZE) too,
I'm going to try re-soldering the wires by gluing them down first and then hot air soldering with paste. At that point, i'll verify with an ohm meter whether or not they are connect to ground.