avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] I2C controller: INT flag a bit leaves me confused !


From: Vincent Trouilliez
Subject: Re: [avr-chat] I2C controller: INT flag a bit leaves me confused !
Date: Tue, 3 Mar 2009 03:49:54 +0100

On Mon, 2 Mar 2009 17:22:21 -0800
address@hidden wrote:

> However, I also note that you probably shouldn't use the TWINT bit to 
> determine
> if the TWI transfer is complete

The datasheet actually explains in the code examples that this flag is
indeed what they watch to determine that an event has occured, then
only they read the status register to see what event was actually
detected on the bus.

As I am trying to debug it presently, my problem right is that simply
requesting a start operation doesn't seem to succeed, because checking
the TWINT flag the way the datasheet and avrlib-c suggest, well it
never returns, hangs in there ! :-/

I am a little baffled and clueless as to what could be wrong in such a
simple attempt ! :-(


        TWBR = 77;              /* Bus at 100 KHz, 16MHz crystal */
        TWSR = 0x00;            /* Prescaler = 1  */

        TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);
        while( !(TWCR & _BV(TWINT)) );

        status = TW_STATUS;
        lcd_put_byte(status);

This simple code ought to produce a start condition and therefore
return a status. But the while() never returns and the status doesn't
print on the LCD. Commenting out the while() does print something, so
indeed it's the TWINT flag not being set by the I2C controller... but
what on earth could possibly keep him from succeeding in generating a
start condition !! I have got pull-ups on both lines, so nothing can
possibly keep the AVR from generating the start ! Oh dear.... not
looking good ! Maybe yet another fired AVR chip, no problem, I got 3
spares in the post today, what a good timing !! ;-)

--
Vince




reply via email to

[Prev in Thread] Current Thread [Next in Thread]