register macros used in smiley book not in avr-libc?

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey guys, I have been going through the smiley mircros book (which is a great book for those just getting started), and am trying to compile the examples under linux, and am running into some undefined macros.

In particular, the Joystick example:

-------- begin --------
avr-gcc (GCC) 3.4.6 (Gentoo 3.4.6, ssp-3.4.5-1.0, pie-8.7.9)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: PC_Comm.c
avr-gcc -c -mmcu=atmega169 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=PC_Comm.lst  -std=gnu99 -Wp,-M,-MP,-MT,PC_Comm.o,-MF,.dep/PC_Comm.o.d PC_Comm.c -o PC_Comm.o
PC_Comm.c: In function `isCharAvailable':
PC_Comm.c:48: error: `UCSR0A' undeclared (first use in this function)
PC_Comm.c:48: error: (Each undeclared identifier is reported only once
PC_Comm.c:48: error: for each function it appears in.)
PC_Comm.c: In function `receiveChar':
PC_Comm.c:55: error: `UDR0' undeclared (first use in this function)
PC_Comm.c: In function `sendChar':
PC_Comm.c:63: error: `UDR0' undeclared (first use in this function)
PC_Comm.c:69: error: `UCSR0A' undeclared (first use in this function)
PC_Comm.c: In function `USARTinit':
PC_Comm.c:100: error: `UBRR0H' undeclared (first use in this function)
PC_Comm.c:101: error: `UBRR0L' undeclared (first use in this function)
PC_Comm.c:104: error: `UCSR0A' undeclared (first use in this function)
PC_Comm.c:104: error: `U2X0' undeclared (first use in this function)
PC_Comm.c:107: error: `UCSR0B' undeclared (first use in this function)
PC_Comm.c:107: error: `RXEN0' undeclared (first use in this function)
PC_Comm.c:107: error: `TXEN0' undeclared (first use in this function)
PC_Comm.c:107: error: `RXCIE0' undeclared (first use in this function)
PC_Comm.c:107: error: `UDRIE0' undeclared (first use in this function)
PC_Comm.c:110: error: `UCSR0C' undeclared (first use in this function)
PC_Comm.c:110: error: `UMSEL0' undeclared (first use in this function)
PC_Comm.c:110: error: `UPM00' undeclared (first use in this function)
PC_Comm.c:110: error: `USBS0' undeclared (first use in this function)
PC_Comm.c:110: error: `UCSZ00' undeclared (first use in this function)
PC_Comm.c:110: error: `UCPOL0' undeclared (first use in this function)
make: *** [PC_Comm.o] Error 1

I grabbed the source for avr-libc-1.4.3 and grepped for some of the above macros and they appear to be missing. Is this something which is only part of winavr?

-jason

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you need to add deprecated.h which MIGHT take care of the problem. Or you can do as the book recommends and get the older (and perfectly fine) version of WinAVR from the book CD or my website and use it as it has the proper register defines to go with the book code examples.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just remove all the "0"s (zeros) from those register names. The USART register numbers were dropped from AVRs with only one USART in a previous release of AVRLibC.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks guys!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abcminiuser wrote:
Just remove all the "0"s (zeros) from those register names. The USART register numbers were dropped from AVRs with only one USART in a previous release of AVRLibC.

- Dean :twisted:

Not quite correct solution. If U try these examples in AVR Studio of coarse the same errors apears. But in debug mode the registers names in AVR Studio includes these zeroes. So, it mean these names are correct. I think the right solution is to edit iom169.h to add names with zeroes.
E.g:
#define UBRRL _SFR_MEM8(0xC4)
#define UBRR0L _SFR_MEM8(0xC4) //added
#define UBRRH _SFR_MEM8(0xC5)
#define UBRR0H _SFR_MEM8(0xC5) //added
and so on...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please file a bug report for the avr-libc project.

Sigh. There has once been a bug report

https://savannah.nongnu.org/bugs...

that dropped the 0s, which matches Atmel's view of that time (2004).
Starting with AVR Studio build 462 (so less than a year ago), Atmel
changed its opinion, and did not only use the new names (always with
a unit number) for new AVRs, but also corrected history, and dumped
these names all over onto devices from many years ago. :-(

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kabron wrote:
abcminiuser wrote:
Just remove all the "0"s (zeros) from those register names. The USART register numbers were dropped from AVRs with only one USART in a previous release of AVRLibC.

- Dean :twisted:

Not quite correct solution. If U try these examples in AVR Studio of coarse the same errors apears. But in debug mode the registers names in AVR Studio includes these zeroes. So, it mean these names are correct. I think the right solution is to edit iom169.h to add names with zeroes.
E.g:
#define UBRRL _SFR_MEM8(0xC4)
#define UBRR0L _SFR_MEM8(0xC4) //added
#define UBRRH _SFR_MEM8(0xC5)
#define UBRR0H _SFR_MEM8(0xC5) //added
and so on...


Nope.

The unequivocal source for the "correct" register names for use with the ATmega169 microcontroller must be Atmel's published datasheet.

And in the current (07/06) revision of that datasheet, the registers are named UCSRA, UCSRB, UCSRC, UBRRH, UBRRL, etc.

*not* UCSR0A, UCSR0B, UCSR0C, UBRR0H, UBRR0L, etc.

So the register names listed in AVR Studio's simulator are actually incorrect.

Until such time as Atmel decides to revise the datasheet again, I would strongly urge against making any changes to avr-libc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK. Now I think so too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> Until such time as Atmel decides to revise the datasheet again,
> I would strongly urge against making any changes to avr-libc.

We are committed to use the XML files as the definitive source of
knowledge (as they are the only thing we could process automatically).

Please folks file a bug report with Atmel if the XML files and datasheet
do not match.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Please folks file a bug report with Atmel if the XML files and datasheet
do not match.

Done.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just a follow-up:

According to the folks at Atmel technical support, the register names as given in the datasheet (UCSRA, UCSRB, etc) are still considered definitive, and a bug report has been filed with the AVR Studio people to correct the XML files.