[En-Nut-Discussion] TWI Initialisation

Dave Armstrong dud.one at ntlworld.com
Thu Feb 9 15:58:06 CET 2006


Peter ,
which compiler version are you using Outb etc is depreciated in Winavr , i 
think from about 2 versions back
you may have a conflict between version of Ethernut and compiler giving you 
unforseen problems or at least no warnings or errors
etc

Dave

----- Original Message ----- 
From: "Peter Sodermanns" <peter.sodermanns at aixcon.de>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Thursday, February 09, 2006 2:48 PM
Subject: Re: [En-Nut-Discussion] TWI Initialisation


> Back to my initial problem:
>
>> TWINT in register TWCR is not set,
>> interrupt routine is never executed,
>> no signals at output pins.
>
> I put some debug output in TwInit:
>
> int TwInit(u_char sla)
> {
> #ifndef __AVR_ENHANCED__
>     return -1;
> #else
>     u_long speed = 2400;
>     printf_P(PSTR("TwInit called\n"));
>     if (NutRegisterIrqHandler(&sig_2WIRE_SERIAL, TwInterrupt, 0)) {
>         return -1;
>     }
>     /*
>      * Set address register, enable general call address, set transfer
>      * speed and enable interface.
> */
>     outb(TWAR, (sla << 1) | 1);
>     TwIOCtl(TWI_SETSPEED, &speed);
>     printf_P(PSTR("1 TWCR = %d\n"), TWCR);
>     outb(TWCR, _BV(TWINT));
>     printf_P(PSTR("2 TWCR = %d\n"), TWCR);
>     outb(TWCR, _BV(TWEN) | _BV(TWIE));
>     printf_P(PSTR("3 TWCR = %d\n"), TWCR);
>     /*
>      * Initialize mutex semaphores.
>      */
>     NutEventPost(&tw_mm_mutex);
>     printf_P(PSTR("TwInit finished\n"));
>     return 0;
> #endif /* __AVR_ENHANCED__ */
> }
>
> resulting in:
>
> Nut/OS:       4.0.2.1
> ...
> TwInit called
> 1 TWCR = 0
> 2 TWCR = 0
> 3 TWCR = 5
> TwInit finished
>
> (Updating Nut/OS didn't change things...)
>
> Is it wrong to expect "TWCR = 128" after the command "outb(TWCR,
> _BV(TWINT));"?
> Why is the TWINT-bit not set?
> And why are there no signals at all at ports D0/D1? At least a start
> condition and sending of slave address I would have expected.
>
>
> Any ideas?
>
>
> Regards
>               Peter
>
>


--------------------------------------------------------------------------------


> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>


--------------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.3/254 - Release Date: 02/08/2006



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.3/254 - Release Date: 02/08/2006




More information about the En-Nut-Discussion mailing list