Using the software implementations of i2c read/write are DREADFULLY SLOW. Yes, I am not surprised you get such a slow loop.
There are several ways to dramatically speed it up.
1. use the hardware i2c--this will speed it up by about 30-40x at least.
2. put the addressing with STARTs, etc, outside the loop, and just clock the data sequentially. This will get you almost 4x improvement.
3. Use a repeat until or do while instead of a for-loop. The For-loop is a lot slower than the other loops when timing is important...but it won't help nearly as much as 1 or 2.
4. Send 256 bytes instead of 255...that way it can init at 0 and loop until 0 again, and that's often a one-instruction savings, depending on the pic.
Bookmarks