IAR linker problem

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

Hi

I use IAR in one project at work (ver 4.11A) with Atmega32 and where UART is one of the features used. In my UART init function, register UBRRH and UCSRC is cleared prior to setting wanted value. (se example code)

1	monitor void UartInit(LONG Baudrate, BYTE Parity)
2	{
3	  UCSRA = TXC;                                 
4	  UCSRB = 0;                     
5
6	  UCSRC = URSEL;
7	  UBRRH = 0;
8	  switch (Baudrate)
9	  {
10	    default:
11	    case 0:
12	      return;
13	
14	    case 9600:
15	      UBRRL = UART_BAUD_RATE_9600;
16	      break;
.
.
.
.

My problem is with line 6 and 7. UCSRC and UBBRH shares the same io location and when linking project i get the following message

Quote:
Warning[w18]: Segment ABSOLUTE (seg part no 2, symbol "_A_UCSRC" in module "UartFullDuplex", address [40-40])
overlaps segment ABSOLUTE (seg part no 1, symbol "_A_UBRRH" in module "UartFullDuplex", address [40-40])

Address 40 is the corresponding data space address for the io register address 20 which holds the UCSRC/UBBRH register (See page 15 of mega32 datasheet for more info).

If someone have any clue of this please give a hint. I have allready spent houres on this, and I expect it to be a simple solution to the problem, but my eyes have fade and my brain wont think clearly any more.

We have earlier used mega16 UART with no such problems, but then with an old IAR compiler (ver 2.20c or something), and we would not like to go back to that old pimp of a compiler

Thanks in advance

Regards
Vidar (Z)

----------------------------------------------------------

"The fool wonders, the wise man asks"

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

I see you are receiving a warning. But it is possible that the code will work correctly. It looks like the linker is warning you about something you already know and this may be ok. Does the code execute as expected?

-Tom

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

looks to me like you have defined the ports manually, instead of using the provided processor includes.... If you want to have separate names for USCRC and UBRRH, use a #define for the 2nd symbol, or a union (which is how IAR does it now).

Older versions of IAR allowed for overlapping segments. This is, appropriately, no longer the case.

Also make sure you use the include that came with the version of the compiler you are using, and not the one from the older IAR version. The way SFR's are generated is quite different.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Yes we do make our own register definition files using the new syntax from IAR, but we have created one SFR part for each of the mentioned registers. When making a define of UBRRH the warning is gone.

Thanks
glitch

Regards
Vidar (Z)

----------------------------------------------------------

"The fool wonders, the wise man asks"