[En-Nut-Discussion] TWI interrupts on AT91SAM7x256 and Ethernut 4.6.5/4.8.0

Ajit Narayanan ajitn at inventionlabs.in
Fri Apr 3 17:36:19 CEST 2009


Hi Harald/Ole,

I made some progress on this bug. It looks like there are a few issues in
at91_twi.c related to the TWI errata of AT91SAM7x256 (41.4.9.1) which says
The value of CLDIV x 2^CKDIV must be less than or equal to 8191, the value
of CHDIV x 2^CKDIV must be less than or equal to 8191.

For a client bitrate of 2400, this is not possible; we need a faster
bitrate. This can be changed in TwInit(). I changed it to 4800.

The return value of the SETSPEED IOCtl is not being checked; this would
have caught the bug earlier:

-   TwIOCtl(TWI_SETSPEED, &speed)
+   if( TwIOCtl(TWI_SETSPEED, &speed) ) {
+	return -1;
+   }

Also, the check in the IOCtl (line 344) is incorrect:
-       if (cldiv * (2 << ckdiv) > 8191) {
+       if (cldiv * (1 << ckdiv) > 8191) {

The bad news is, with all of the above, my application still doesn't work
:-(. But when I check with a scope, I see that at least master
transactions are initiated now. If someone with a Calypso board could give
it a shot and let me know, that would be great.

It is still a mystery to me why this works with older Nut/OS versions.


-Ajit


> Ole Reinhardt wrote:
>
>> Ok, I had it just running with a client, but the above bug is realy a
>> bug :)
>
> On a SAM7X? May be there's a difference among MCUs.
>
>
>> I'll test it here any further if I get a I2C device connected to my
>> olimex board. Until then you might add a hint to the configurator option
>> not to use this code right now...
>
> No hurry.
>
> Unfortunately here is a second problem. Both, the hardware TWI as well
> as the bit banging version are added to the libs. It seems they are
> added by random, depending on the sequence of the referrers.
>
> As a temporary workaround one might copy twbbif.c to the application
> directory and add it to the Makefile.
>
> Harald
>
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>






More information about the En-Nut-Discussion mailing list