2 byte i2c register selection

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: 99jonathan, roger, imaqine

2 byte i2c register selection

Postby rcblob » Wed Jan 21, 2009 6:02 pm

Hi all,

I am currently trying to interface with an i2c eeprom chip, the problem being I need to be able to send two register values(MSB + LSB) for R/W
i.e. :[deviceId+(r/w)] ack [Address hi] ack [Address low] ack [Data]
I did notice the sendData()/readData method in I2CSensor uses an int for register selection, will this automatically adjust for longer addresses?
i.e. does 0xFFFF get converted to 0xFF + 0xFF?
How else would I go about longer register addressing?

Cheers,
Mike
rcblob
New User
 
Posts: 4
Joined: Wed Jan 21, 2009 5:48 pm

Postby gloomyandy » Wed Jan 21, 2009 6:59 pm

Hi Mike,
Unfortunately I don't think this will work. The current i2c code is only setup to handle a single byte for register selection. If you only need to write to the device then it would be possible to simply combine the register address with the data, however to read from the device will probably require a change to the firmware (due to the need to do a restart to change the transfer direction).

The actual changes are not very large since we already pass a byte count for the internal address size. Unfortunately we don't actually use it (other then to test if there is an internal address at all)! I can probably make the changes but I will have no way of testing them.... If you are prepared to switch to using a snapshot of the developer build then I can probably work with you to try and get this working...

Do you already have a working leJOS install?
What host system do you use?

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3967
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby rcblob » Thu Jan 22, 2009 12:27 pm

Hey Andy,

Thanks for the quick reply. Sounds like a deal :). I'm a bit busy at the moment (final year uni exams...), but I’ll be ready to try at the beginning of February.

I was thinking about mixing register address with the data, and then creating an adapter (an atmega8 with a bit of asm) to read back 1024 byte blocks (its a 256K eeprom) but of course direct addressing would be better/easier.

I've currently got LeJOS 0.7 working and have been familiarising my-self with it as I'm planning to use it in my dissertation.
I’m using WinXp and Ubuntu on my laptop with eclipse and the LeJOS 0.7 plugin.

Thanks,

Mike.
rcblob
New User
 
Posts: 4
Joined: Wed Jan 21, 2009 5:48 pm

Postby gloomyandy » Thu Jan 22, 2009 12:30 pm

Hi,
Sounds good... Let me know when you are ready to give it a go and I'll walk you through the process of using the svn snapshot and create a new version of the firmware with the changes in it...

all the best

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3967
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff