[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] Problem with debbuggin with AVRStudio, WinAvr and Jta

From: Dave Hansen
Subject: RE: [avr-gcc-list] Problem with debbuggin with AVRStudio, WinAvr and JtagIce mkII
Date: Wed, 16 Nov 2005 09:20:26 -0500

From: address@hidden
#include <avr/io.h>

int somma(int a, int b)

                return a+b;

int main ()
{               int e = 10;
                int r = 1;
                r = somma(e,r);
                                return r;

it's a stupid program. When debbugging it step by step the main regularly calls somma(e,r). After somma(e,r) finished, the control flow does not return in main at r=r+1 but in a part of memory without code (after the exit() of the main). Can you help me with this problem?

Just a guess:  Try making 'r' volatile, i.e., change the declaration of r to

  int volatile r = 1;

Because r is not used other than as the return value, the compiler might be optimizing out accesses to the variable itself. The 'volatile' declaration forces the compiler to retain these accesses.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]