I2C Issue.... WARNING involes math
Ravenkallen
Posts: 1,057
So i have played around with i2c eeprom interfaced to the propeller. I have had some issues regarding speed. Tell me if i am wrong. I am assuming the objects use i2c fast mode, and i am reading one byte at a time. The i2c fast mode is 400 khz, if that means that is takes one cycle to clock in a bit and there are 8 bits in a byte, we should have a theoretical read time of 50 kilobytes a second. If there are four bytes(Slave Address and w/r bit, Memory address, data byte to be received)·needed to complete a·read cycle that would leave 12.5 kilobytes a second. Plus if you add a little time for the propeller to process, i would·say we·have a speed of roughly 10 kilobytes a second. Problem is,·all the objects·i tried·only gave me roughly 500 bytes a second, which is way to slow for my application. I know that you can read from the eeprom sequentially to save·even more time, but still, i don't get it. Even if the object was using i2c·slow mode it would still·yield about 2.5 kilobytes a second. IF I am doing something wrong, please let me know. I·Know the propeller is fast enough, but maybe the objects are·just to slow...Calling anybody with knowledge of i2c and the propeller...·
Comments
If you're using Basic_I2C_Driver, this is written in Spin so that will slow down the transfer rates. If you use sdspiFemto, the default speed is 100KHz. You have to override the default to get a 400KHz speed.
BTW, I measured a write speed of 250 bytes/second.· I also used page mode for this.· I basically wrote 400-byte chunks of memory, which were broken up into seperate 64-byte pages.· This means the boundary pages were written twice in my test, so the optimal write speed would be somewhat higher than 250 bytes/second.· However, an assembly driver won't help this much.
Dave
Something is very wrong there. That would suggest 32k in ~131 seconds. I've never seen the propeller bootloader take that long to write an eeprom.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
PUB readEEPROM(addr,buffer,count) | t '' Read a block from EEPROM to RAM
PUB writeEEPROM(addr,buffer,count) | t '' Write a block to EEPROM from RAM
PUB writeWait(addr) | t '' Wait for EEPROM to complete write
PUB start(ctrlBlk) | t '' Start the I2C I/O driver (standalone)
For readEEPROM, writeEEPROM, and writeWait, "addr" is the EEPROM address (including the I/O pin numbers as described in the comments). "buffer" is the address of the data to be read or written, and "count" is the number of bytes to be transferred in a single transfer. For reads, the data must lie completely within a single EEPROM. For writes, the data must fit within a single EEPROM page (typically 64 or 128 bytes). For start, "ctrlBlk" is the address of a two long work area used to communicate with the PASM routine.
Edit: I modified my code to keep track of the last allocated block, and it now writes about 1,260 byte/second.· It's still about 10x slower than the theoretical max of 12,800 bytes/second, but it's getting better.· There's a few more things I can do to speed it up, and then I'll have to go to a PASM driver to get any more gain.
Dave
Post Edited (Dave Hein) : 5/2/2010 8:04:08 PM GMT