Yahoo Groups archive

AVR-Chat

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

Thread

WinAvr TWI include files

WinAvr TWI include files

2010-12-29 by Steve Hodge

I am trying to get up and running with TWI/I2C using WinAvr under AVR
Studio, but when I go to compile sample TWI/I2C C files (from AvrFreaks,
etc) some symbolic constants, like TWEN, are missing.  I am doing this for a
ATmega644P controller and this is set in my Project Configuration in AVR
Studio. I can otherwise program the controller just fine with non-TWI code.

My installation of WinAvr has the following include folder structure:


WinAvr\avr\include
WinAvr\avr\include\avr
WinAvr\avr\include\avr\compat(*)
WinAvr\avr\include\compat(*)
WinAvr\avr\include\util(*)

There is a TWI.H file in each of the (*) folders.

If I search all the files under ...\include for TWEN, the only one that
seems somewhat relevant to the ATmega644P is a file with name IOM644PA.H
(with an "A" appended).  But the Project Configuration/Compile does not seem
to use this file.

The above folder structure is very confusing.  Why, for one thing, the
multiple TWI.H files?

Can someone please straighten me out on this?   I've been battling this for
a couple of days now and getting nowhere.

Thanks, Steve




 

__________ Information from ESET Smart Security, version of virus signature
database 5742 (20101229) __________

The message was checked by ESET Smart Security.

http://www.eset.com

Re: WinAvr TWI include files

2010-12-29 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Steve Hodge" <steve@...> wrote:
>But the Project Configuration/Compile does
>not seem to use [the file iom644PA.h].
The part-specific include file will be included automatically if:
1) you include "avr/io.h"
2) you properly define the target MCU so that it gets passed to the compiler via the -mmcu option.

Failure to do either of these will result in the register/bit names not being present.

> Why, for one thing, the multiple TWI.H files?
The avr-libc documentation suggests including "util/twi.h".  Why not just follow that advice?  The other twi.h files may be in their respective locations for backward compatibility with previous versions.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

RE: [AVR-Chat] Re: WinAvr TWI include files

2010-12-29 by Steve Hodge

Don, I think I have those things correctly.   Here are the include files (in
order):

 

#include <inttypes.h>

#include <stdio.h>

#include <stdlib.h>

#include <avr/io.h>

 

and here is the compile line generated and the first few error messages:

 

avr-gcc -I"C:\Program Files\WinAVR\avr\include\avr" -I"C:\Program
Files\WinAVR\avr\include\util"  -mmcu=atmega644p -Wall -gdwarf-2 -Os
-std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-MD -MP -MT I2C.o -MF dep/I2C.o.d  -c  ../I2C

.c

 

../I2C.c: In function 'ioinit':

../I2C.c:106: error: 'TXEN' undeclared (first use in this function)

../I2C.c:106: error: (Each undeclared identifier is reported only once

.........

 

Roger on the reason for the other twi.h files.   Does that mean I can delete
those other include directories if I know I'll never need to go backwards?

 

Steve
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Don Kinzer
Sent: Wednesday, December 29, 2010 10:54 AM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Re: WinAvr TWI include files

 

  

--- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> , "Steve
Hodge" <steve@...> wrote:
>But the Project Configuration/Compile does
>not seem to use [the file iom644PA.h].
The part-specific include file will be included automatically if:
1) you include "avr/io.h"
2) you properly define the target MCU so that it gets passed to the compiler
via the -mmcu option.

Failure to do either of these will result in the register/bit names not
being present.

> Why, for one thing, the multiple TWI.H files?
The avr-libc documentation suggests including "util/twi.h". Why not just
follow that advice? The other twi.h files may be in their respective
locations for backward compatibility with previous versions.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net





__________ Information from ESET Smart Security, version of virus signature
database 5742 (20101229) __________

The message was checked by ESET Smart Security.

http://www.eset.com

 

__________ Information from ESET Smart Security, version of virus signature
database 5742 (20101229) __________

 

The message was checked by ESET Smart Security.

 

http://www.eset.com



[Non-text portions of this message have been removed]

RE: [AVR-Chat] Re: WinAvr TWI include files

2010-12-29 by wagnerj@proaxis.com

There is no TXEN in a 644. It is TXEN0 or TXEN1.

Jim Wagner
Oregon Research Electronics
Show quoted textHide quoted text
> Don, I think I have those things correctly.   Here are the include files
> (in
> order):
>
>
>
> #include <inttypes.h>
>
> #include <stdio.h>
>
> #include <stdlib.h>
>
> #include <avr/io.h>
>
>
>
> and here is the compile line generated and the first few error messages:
>
>
>
> avr-gcc -I"C:\Program Files\WinAVR\avr\include\avr" -I"C:\Program
> Files\WinAVR\avr\include\util"  -mmcu=atmega644p -Wall -gdwarf-2 -Os
> -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct
> -fshort-enums
> -MD -MP -MT I2C.o -MF dep/I2C.o.d  -c  ../I2C
>
> .c
>
>
>
> ../I2C.c: In function 'ioinit':
>
> ../I2C.c:106: error: 'TXEN' undeclared (first use in this function)
>
> ../I2C.c:106: error: (Each undeclared identifier is reported only once
>
> .........
>
>
>
> Roger on the reason for the other twi.h files.   Does that mean I can
> delete
> those other include directories if I know I'll never need to go backwards?
>
>
>
> Steve
>
>
>
> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
> Of Don Kinzer
> Sent: Wednesday, December 29, 2010 10:54 AM
> To: AVR-Chat@yahoogroups.com
> Subject: [AVR-Chat] Re: WinAvr TWI include files
>
>
>
>
>
> --- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> ,
> "Steve
> Hodge" <steve@...> wrote:
>>But the Project Configuration/Compile does
>>not seem to use [the file iom644PA.h].
> The part-specific include file will be included automatically if:
> 1) you include "avr/io.h"
> 2) you properly define the target MCU so that it gets passed to the
> compiler
> via the -mmcu option.
>
> Failure to do either of these will result in the register/bit names not
> being present.
>
>> Why, for one thing, the multiple TWI.H files?
> The avr-libc documentation suggests including "util/twi.h". Why not just
> follow that advice? The other twi.h files may be in their respective
> locations for backward compatibility with previous versions.
>
> Don Kinzer
> ZBasic Microcontrollers
> http://www.zbasic.net
>
>
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature
> database 5742 (20101229) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature
> database 5742 (20101229) __________
>
>
>
> The message was checked by ESET Smart Security.
>
>
>
> http://www.eset.com
>
>
>
> [Non-text portions of this message have been removed]
>
>

RE: [AVR-Chat] Re: WinAvr TWI include files

2010-12-29 by Steve Hodge

Ah, thank you.  That did it.  Steve
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of wagnerj@proaxis.com
Sent: Wednesday, December 29, 2010 11:46 AM
To: AVR-Chat@yahoogroups.com
Subject: RE: [AVR-Chat] Re: WinAvr TWI include files

 

  

There is no TXEN in a 644. It is TXEN0 or TXEN1.

Jim Wagner
Oregon Research Electronics

> Don, I think I have those things correctly. Here are the include files
> (in
> order):
>
>
>
> #include <inttypes.h>
>
> #include <stdio.h>
>
> #include <stdlib.h>
>
> #include <avr/io.h>
>
>
>
> and here is the compile line generated and the first few error messages:
>
>
>
> avr-gcc -I"C:\Program Files\WinAVR\avr\include\avr" -I"C:\Program
> Files\WinAVR\avr\include\util" -mmcu=atmega644p -Wall -gdwarf-2 -Os
> -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct
> -fshort-enums
> -MD -MP -MT I2C.o -MF dep/I2C.o.d -c ../I2C
>
> .c
>
>
>
> ../I2C.c: In function 'ioinit':
>
> ../I2C.c:106: error: 'TXEN' undeclared (first use in this function)
>
> ../I2C.c:106: error: (Each undeclared identifier is reported only once
>
> .........
>
>
>
> Roger on the reason for the other twi.h files. Does that mean I can
> delete
> those other include directories if I know I'll never need to go backwards?
>
>
>
> Steve
>
>
>
> From: AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com>
[mailto:AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> ] On
Behalf
> Of Don Kinzer
> Sent: Wednesday, December 29, 2010 10:54 AM
> To: AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> 
> Subject: [AVR-Chat] Re: WinAvr TWI include files
>
>
>
>
>
> --- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com>
<mailto:AVR-Chat%40yahoogroups.com> ,
> "Steve
> Hodge" <steve@...> wrote:
>>But the Project Configuration/Compile does
>>not seem to use [the file iom644PA.h].
> The part-specific include file will be included automatically if:
> 1) you include "avr/io.h"
> 2) you properly define the target MCU so that it gets passed to the
> compiler
> via the -mmcu option.
>
> Failure to do either of these will result in the register/bit names not
> being present.
>
>> Why, for one thing, the multiple TWI.H files?
> The avr-libc documentation suggests including "util/twi.h". Why not just
> follow that advice? The other twi.h files may be in their respective
> locations for backward compatibility with previous versions.
>
> Don Kinzer
> ZBasic Microcontrollers
> http://www.zbasic.net
>
>
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature
> database 5742 (20101229) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature
> database 5742 (20101229) __________
>
>
>
> The message was checked by ESET Smart Security.
>
>
>
> http://www.eset.com
>
>
>
> [Non-text portions of this message have been removed]
>
>





__________ Information from ESET Smart Security, version of virus signature
database 5743 (20101229) __________

The message was checked by ESET Smart Security.

http://www.eset.com

 

__________ Information from ESET Smart Security, version of virus signature
database 5743 (20101229) __________

 

The message was checked by ESET Smart Security.

 

http://www.eset.com



[Non-text portions of this message have been removed]

Re: WinAvr TWI include files

2010-12-29 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Steve Hodge" <steve@...> wrote:
> and here is the compile line generated [...]
I believe that the first two -I options are superfluous; I don't use them and I can compile without errors.  (Perhaps you added them in an effort to solve the problem you were having.)  On the other hand, if you do have them, you can omit the avr/ and util/ prefixes since you're supplying a path to those specific directories.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

RE: [AVR-Chat] Re: WinAvr TWI include files

2010-12-29 by Steve Hodge

Yeah, I did exactly that, added them to my project config while trying to
solve the issue.   You're right, works just as well without them in the
project config (and thus gone from the command line).   Steve
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Don Kinzer
Sent: Wednesday, December 29, 2010 1:12 PM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Re: WinAvr TWI include files

 

  

--- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> , "Steve
Hodge" <steve@...> wrote:
> and here is the compile line generated [...]
I believe that the first two -I options are superfluous; I don't use them
and I can compile without errors. (Perhaps you added them in an effort to
solve the problem you were having.) On the other hand, if you do have them,
you can omit the avr/ and util/ prefixes since you're supplying a path to
those specific directories.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net



[Non-text portions of this message have been removed]

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.