Optimizing problem

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

Hi,

I am A littlebit frustrated at the moment.
My version of the AS5 is at the bottom of this topic.

If I go from 03,0s to 0o everything works just find in some parts of my code. If I enable 0s or 03 I get strange thing to happen.

This function for example is returning wrong values.
Inside my uart_getchar_forground_rf_short() I could read the correct value which is 0xFF00. but the pi_temp.SOURCEID is set to zero after this two lines (yes, I am sure that my getchar returns 0xFF00).

int uart_getchar_foreground_rf_short() 
{
	unsigned char data;

    if (uartRf.foreground_rx_head_short == uartRf.RxTailShort) 
	{ 		 
		return EOF;   /* no data available */
	}

	data = uartRf.RxBuf[uartRf.RxTailShort];

    uartRf.RxTailShort = ((uartRf.RxTailShort + 1) & RxMask);
    
	return (int)data;
}
		uint16_t test1 = uart_getchar_foreground_rf_short();	
		uint16_t test2 = uart_getchar_foreground_rf_short(); 
		pi_temp.SOURCEID = ((uint16_t)uart_getchar_foreground_rf_short() << 8);	
		pi_temp.SOURCEID |= (uint16_t)uart_getchar_foreground_rf_short(); 

If I use the following I am able to read 0xFF to test1 and 0x00 to test2

This code has been runned on the AS4 with GCC for over a year without this problem.
What is it to do. This kind of problem is one of the worst I think. Is it best to not use optimizing? That is not the common way of doing thing but Right know I cant see other solutions.

Regards ellile

    Atmel AVR Studio 5 (Version: 5.0.1163) © 2011 Atmel Corp.
    All rights reserved.
    AVR GCC 8-bit Toolchain
    Version: gcc version 4.5.1 (AVR_8_bit_GNU_Toolchain_3.2.3_315)

    AVR GCC 32-bit Toolchain
    Version: gcc version 4.4.3 (AVR_32_bit_GNU_Toolchain_3.2.3_261)

    AVR Software Framework
    Version: ASF-2.5.1-17860.53

Br Leif G

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

Post the .lss

As this could well be a bug in "AVR Toolchain" I'll move this thread to AS5/6 forum.

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

Her is the .lss file

Br Leif G

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

ellile wrote:
Her is the .lss file
I don't see any attachment.

ellile wrote:
I am A littlebit frustrated at the moment.
I can relate to that. This looks like it might be the same or similar to the problem I reported a couple of days ago in this thread. I see this problem with AVR Studio 5.0, 5.1 and 6.0 - beta. I've been getting around it by using WinAVR-20100110 with AVR Studio 6.0 - beta.

Don

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

avrfreaks does not support Opera. Profile inactive.

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

You are right. I tried to attach it without luck, I am not sure why this not work for me.
Ok So you have the same problem. Yes at the moment iam more than frustrated. I have been told to use volatile on all global variables and in some places of my code It seems to work but not in all parts.
How do you add the WINAVR version into AS5?

Br Leif G

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

ellile wrote:
How do you add the WINAVR version into AS5?
Select Tools, then Options.... Expand Toolchan (at the bottom) and select Flavour Configuration. In Toolchans: select Atmel AVR 8-bit. Click on Add Flavour. Give the flavor a name and select the Toolchain Path (e.g., c:\WinAVR-20100110\bin).

Now open your project properties. Select Advanced and then select the Toolchain Flavour you created for WinAVR.

Don

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

I too had this issue with AS5.1.148 and 5.1.208. I tried to use WinAVR-20100110, as suggested by Don, but I still got weird errors in my project, like variables that should be reporting the value 10, instead reporting 2405.

I've run into one issue with 5.0.1223 where I've had to declare a local variable as volatile in order to keep its upper 8 bits from being optimized away.

Oh if only we could remove the human element from compilers....

Aaron

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

About your local volatile, I have also needed to to so in order to make a if statement work.Thanks for the replies. At the moment I have started the AS4, and og course everything works. I understand from Sprinter that it could be related to a bug fixed in 4.6.2? Is that a released version?

Br Leif G

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

ellile wrote:
I understand from Sprinter that it could be related to a bug fixed in 4.6.2? Is that a released version?
Yes, of course, see "Release Series and Status" at http://gcc.gnu.org/

See also the end of the "GCC 4.6.x (changes)" subpage that lists the problems fixed in 4.6.2, for example. There are at least 5 problems fixed in 4.6.2, amongst them PR46779.

For the Atmel compiler ask Atmel. That compiler is based on GCC but uses own versioning, adds special features and optimizations etc. for their users. Atmel has considerably more manpower than there are people that are inclined to contribute to avr-gcc, so it's very likely Atmel has a release available with this issue fixed for you for.

avrfreaks does not support Opera. Profile inactive.

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

Atmel says that this bugfix is not released in their version. They say that it should be included in the AS6 version. I assume that this is not the case for the beta that is out now. I have gone back to the AS4 at this stage but will give the AS6 a try when it is released.

Thanks for all tips.

Br Leif G