[Top][All Lists]

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

Re: [avr-gcc-list] How to reserve registers

From: Omar Choudary
Subject: Re: [avr-gcc-list] How to reserve registers
Date: Wed, 4 Jan 2012 09:52:53 +0000

I thought this (declaring a variable as volatile) applies only when we are
using the variable in C, i.e. when the compiler needs to know that
variable will be modified by hardware/ISR.

However in this case the variable is modified only in assembler and the
function used to retrieve the value (GetCounter) is also written in assembler.

Does it really make a difference in this case if the variable is declared as
volatile or not?


On Tue, Jan 3, 2012 at 9:48 PM, Volker Kuhlmann
<address@hidden> wrote:
> On Wed 04 Jan 2012 01:50:46 NZDT +1300, Omar Choudary wrote:
> Whenever you declare a variable in C/C++ that is being modified by
> something other than your program, e.g. ISR or hardware, you have to
> declare that variable volatile. Failure to do so means your program may
> only work intermittently.
> You are missing the volatile declaration for your counter variable.
> Volker
> --
> Volker Kuhlmann
> http://volker.dnsalias.net/     Please do not CC list postings to me.
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

reply via email to

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