by i-Bot » Mon Sep 03, 2007 11:04 pm
by i-Bot
Mon Sep 03, 2007 11:04 pm
I have just implemented and tested a patch to the C3024 code to add a second i2c master port.
I eventually decided to make the patch as flexible as possible to allow any I2C device to be controlled. This is a little slower than originally planned, but still much faster than bit banging.
I added new I/O ports ( 6 and 7) for the BYTEIN and BYTEOUT commands to give an I2C control/status and data transfer register. This allows the new I2C commands to be called from RoboBASIC directly.
I left the C3024 code as unchanged as possible, and retained nearly all the existing code at its previous locations. I added the I2C routines at the end.
I timed the original bit bang code for the SP03 from NovaOne given above, and it takes about 2 seconds for just the I2C part. The new RoboBasic program with the new i2c instructions takes about 35 milliseconds for the same code.
I have put the Robobasic code and the C3024 code here:
http://robosavvy.com/Builders/i-Bot/C3024i2c.zip
The C3024 code needs to be loaded with Roboflash or similar loader.
I have only tested the SP03 code so far, but if anyone wants to try other devices, I can work with them.
The code should handle most devices and includes handling of ACK/NAK on both write and read.
I have just implemented and tested a patch to the C3024 code to add a second i2c master port.
I eventually decided to make the patch as flexible as possible to allow any I2C device to be controlled. This is a little slower than originally planned, but still much faster than bit banging.
I added new I/O ports ( 6 and 7) for the BYTEIN and BYTEOUT commands to give an I2C control/status and data transfer register. This allows the new I2C commands to be called from RoboBASIC directly.
I left the C3024 code as unchanged as possible, and retained nearly all the existing code at its previous locations. I added the I2C routines at the end.
I timed the original bit bang code for the SP03 from NovaOne given above, and it takes about 2 seconds for just the I2C part. The new RoboBasic program with the new i2c instructions takes about 35 milliseconds for the same code.
I have put the Robobasic code and the C3024 code here:
http://robosavvy.com/Builders/i-Bot/C3024i2c.zip
The C3024 code needs to be loaded with Roboflash or similar loader.
I have only tested the SP03 code so far, but if anyone wants to try other devices, I can work with them.
The code should handle most devices and includes handling of ACK/NAK on both write and read.