avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Best practice for external variable (newbie-ish question)


From: Matthew Smith
Subject: [avr-gcc-list] Best practice for external variable (newbie-ish question)
Date: Sun, 20 Nov 2005 11:22:46 +1030
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Hi All

I am writing a small programme where I need a couple of variables to be
accessible to various routines, including an ISR.

I have declared the variables in the main body of the programme as
volatile, as I believe that this is required for access by the ISR:

volatile uint8_t foo;
volatile uint8_t bar;

1) Am I correct in thinking that I need to declare this in the ISR thus:

SIGNAL(SIG_OUTPUT_COMPARE1A)
{
        extern uint8_t foo;
        foo++;
        // Other stuff
}

2) Is this the correct way to access it in an ordinary routines, or
should I be doing something with references?

void startclock(void)
{
        extern uint8_t bar;
        // Various stuff
        bar=1;
}

Comments/suggestions would be greatly appreciated.

Cheers

M

-- 
Matthew Smith
Work: <http://www.kbc.net.au> | Home: <http://www.mss.cx>

The time here is 11:20 and the temperature outside is 27.3°C; today's
maximum is 29.5°C with a minimum of 10.1°C.  We have had 0.0mm of rain
today, with a total of 0.0mm in the last week.  The wind is currently
due WSW, light air, force 1 (3.3mph), gusting to light breeze, force 2
(6.3mph).




reply via email to

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