avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] TWI


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] TWI
Date: Thu, 2 Jan 2003 14:13:12 +0100 (MET)

[Late reply, sorry.]

"Daniel Williamson" <address@hidden> wrote:

> I've been fighting the TWI interface on a mega 128 for a couple of
> days now just so I can set a couple of digital pots.

Btw., i recently added a demo project to the CVS repository.  As soon
as Ted refreshs the Webpage, it should appear there.  However, being a
demo project, i tried to make it as simple as possible (it's still
quite large since TWI is a bit complex), so it doesn't use interrupts.

> To make it work I've ended up clearing the interrupt myself before
> exiting the interrupt service routine. the other thing is that on
> the datasheet it states that the TWSTA Start bit is cleared when the
> start bit is sent and so I took it to mean that it was cleared by
> the hardware.

Well, the best way is to explicitly all bits each time anyway.  At
least on the ATmega128, the TWI control registers live in extended IO
register address space, so they are only accessible by memory
instructions.  If you use sbi() (or TWCR |= ...), you'll force the
compiler to do a memory read, ORI, memory write.

The examples in the datasheet also always use explicit assignments.
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/
avr-gcc-list at http://avr1.org



reply via email to

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