Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Looking for i2c (TWI) using USI example (AVR Butterfly ATmega169)

2006-12-19 by David Kelly

On Tue, Dec 19, 2006 at 01:38:29PM -0800, Dave Hylands wrote:
> 
> I mean, lots of people do bit-banged i2c. Using USI allows the
> hardware to deal with a bunch of the bit manipulations. So using USI
> will consume less CPU than using bit-banged i2c. But bit-banged i2c is
> probably easier to understand just by looking at the code and is
> probably portable to many more platforms.

Sometimes (on SPI that I know of) the target hardware has registers
which are not multiples of 8 bits. One can bitbang shift exactly the
proper amount of bits and alignment in CPU variables is totally under
your own control.

If using hardware SPI one typically must shift multiples of 8 bits.
Generally this isn't a problem for odd sized SPI targets but one has to
know where these extra bits end up on the target. Hopefully in the bit
bucket. Usually the last bits one sends are the important bits, but the
first bits one receives are the important bits.

Sometimes I use hardware, sometimes I bit bang, it all depends on the
situation.

-- 
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.