Yahoo Groups archive

AVR-Chat

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

Thread

TWI on ATMega16 vs ATMega128

TWI on ATMega16 vs ATMega128

2009-01-05 by englsprogeny

I have code running on my ATMega128. The software is TWI/I2C (talking
to a DS1307).   When I compile it for my ATMega16, it gets stuck in
the following file:

TWI.C

At the following location: 

WAIT_FOR_TWINT \
  for ( \
       toCounter = toValue; \
       ( toCounter != 0 ) && ( ( TWCR & _BV( TWINT ) ) == 0 ); \
  )


I am using GCC.

Why does it not get stuck here when running on the Mega128 but does
get stuck when running on my Mega16?

I know it gets stuck here because I am using the UART to trace code
[with Windows Terminal].

I have been playing with GCC for a year now.  Is CodeVision (or some
other compiler) easier to work with?

Thanks.

Re: [AVR-Chat] TWI on ATMega16 vs ATMega128

2009-01-05 by John Samperi

At 02:51 PM 5/01/2009, you wrote:
>I have code running on my ATMega128. The software is TWI/I2C (talking
>to a DS1307).   When I compile it for my ATMega16, it gets stuck in
>the following file:

How are the 2 modules wired up? ie pull-up resistors for the I2C etc.

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: TWI on ATMega16 vs ATMega128

2009-01-06 by englsprogeny

Hi John,

Both configurations have 4.7K pullups for the clock and data lines.

ATMega16 pin-22 to  DS1307 pin-6 (SCL)
ATMega16 pin-23 to  DS1307 pin-5 (SDA)


ATMega128 pin-25 to  DS1307 pin-6 (SCL)
ATMega128 pin-26 to  DS1307 pin-5 (SDA)


I am using a separate breadboard for the DS1307.  This board has the
pullups, battery, and crystal.


I know that the hardware works (as this works correctly with the
ATMega128).


I am using TWI.C  /TWI.H
GCC version: WinAVR-20080610


Both Processors are running at 8MHz.

When I look at the signal with my logic analyzer, I see that the
ATMega128 is working [The ATMega16 is not].

The ATMega16 is functional (as it runs other software correctly).

So... the software should not change when going from the ATMega128 to
the ATMega16?

I'm going to look into this more (now that I'm home from work).  The
mad hobby guy can't be stopped!

Thanks for your input, John.

Cheers.

David










--- In AVR-Chat@yahoogroups.com, John Samperi <samperi@...> wrote:
Show quoted textHide quoted text
>
> At 02:51 PM 5/01/2009, you wrote:
> >I have code running on my ATMega128. The software is TWI/I2C (talking
> >to a DS1307).   When I compile it for my ATMega16, it gets stuck in
> >the following file:
> 
> How are the 2 modules wired up? ie pull-up resistors for the I2C etc.
> 
> Regards
> 
> John Samperi
> 
> ********************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495       Fax (02) 9674-8745
> Website  http://www.ampertronics.com.au
> *Electronic Design * Custom Products * Contract Assembly
> ********************************************************
>

Re: TWI on ATMega16 vs ATMega128

2009-01-06 by englsprogeny

John,

I got it.  This board I am playing with (this one is new to me) isn't
wired as I expected.  They put jumpers along both sides of the
ATMega16.  I assumed that the jumpers were for the pins that they were
closest to....  I was wrong.  They actually routed the traces so that
the ports were grouped!

The ATMega16 is now talking to the DS1307.

Now I'm going to make a Mega8 talk as a slave to the Mega16.

Thanks again, John.

Cheers.

David 

--- In AVR-Chat@yahoogroups.com, John Samperi <samperi@...> wrote:
Show quoted textHide quoted text
>
> At 02:51 PM 5/01/2009, you wrote:
> >I have code running on my ATMega128. The software is TWI/I2C (talking
> >to a DS1307).   When I compile it for my ATMega16, it gets stuck in
> >the following file:
> 
> How are the 2 modules wired up? ie pull-up resistors for the I2C etc.
> 
> Regards
> 
> John Samperi
> 
> ********************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495       Fax (02) 9674-8745
> Website  http://www.ampertronics.com.au
> *Electronic Design * Custom Products * Contract Assembly
> ********************************************************
>

Re: [AVR-Chat] Re: TWI on ATMega16 vs ATMega128

2009-01-06 by John Samperi

At 12:49 PM 6/01/2009, you wrote:
>So... the software should not change when going from the ATMega128 to
>the ATMega16?

Shouldn't be..but then again. I think I have run some test code
for both processors some time ago but I'm only a relatively new
convert to I2C despite having some 20 years old data books
(1996 real paper).

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

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.