Updated - Re: [PicForth] ANN: libi2c.fs

David McNab david at rebirthing.co.nz
Sun Nov 14 05:11:25 CET 2004


Hi,

Thanks to JCWren's prompting, I've updated libi2c.fs to support 
sequential read and write operations, via:
   - i2c.read-begin  ( addrL addrH status )
   - i2c.read-byte   ( -- byte )
   - i2c.read-end    ( -- )
   - i2c.write-begin ( addrL addrH status )
   - i2c.write-byte  ( byte -- )
   - i2c.write-end   ( -- )

Usual rules apply for writes - via 'i2c!' and sequential:
   - after calling i2c! or i2c.write-end, wait 5ms for the 24xxnnn to
     complete the operation (24xxnnn datasheet, table 1.2,
     AC characteristics, parameter 17, Twc)
   - sequential reads can span the whole device, but sequential writes
     roll over within 64-byte pages

The new version is a complete re-write, where i2c! and i2c@ use the 
sequential read/write words, instead of users writing loops that use 
i2c@ and i2c!.

With this new version, my on-host+on-pic I2C programmer utility now 
works n times faster :)

Cheers
David


J.C. Wren wrote:
> David,
> 
>    That looks really good.  The one thing I noticed is there are no 
> mechanisms for block reads and write.  Trivial block operations can, of 
> course, be implemented as a loop, however, this results in the I2C 
> address and 16 bit memory address being sent every byte written.  Writes 
> also have the problem of taking up to 5ms per byte in most parts (worst 
> case), which means writing a chunk of memory gets really slow.
> 
>    If you're interested in a block reads and writes that are fairly 
> efficient, take a look at this: <URL: 
> http://linux.private.com/embedded/Forth/PICForth/demo_i2c.fs >.
>    --jc
> 
> David McNab wrote:
> 
>> Hi,
>>
>> Just announcing a new module, libi2c.fs.
>>
>> Features:
>>  - for accessing medium-to-large I2C serial EEPROMS
>>    such as 24xx128, 24xx256, 24xx512
>>  - 16-bit addresses
>>  - PIC-as-I2C-master
>>  - uses (requires) on-chip MSSP module, present on
>>    some PICs (16F87x[A] etc), but not on others (eg 16F84)
>>  - 3 simple words - i2c.init, i2c@ and i2c!
>>
>> Refer PicForth wiki - http://wiki.enst.fr/bin/view/Picforth/Libi2cfs
>>
> 
> 
> 


More information about the PicForth mailing list