[Top][All Lists]

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

Re: [avr-gcc-list] Best practice for external variable (newbie-ish quest

From: Russell Shaw
Subject: Re: [avr-gcc-list] Best practice for external variable (newbie-ish question)
Date: Mon, 21 Nov 2005 14:51:09 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.11) Gecko/20050914 Debian/1.7.11-1

Matthew Smith wrote:
Hi David

<snip />

The only time I use "extern" is for prototyping in #include files.  Even
so, the variable has to be declared somewhere without "extern"  and
outside of a function in order to create the allocation. Make  sure you
#include the prototype file in the source file which creates  the
storage for the variable because avr-gcc will bellyache if the  two do
not match. This is one of the ways one makes the compiler  double-check
one's work.

Thanks for that; I do have everything in one file and I'm getting some
very, very odd and unpredictable actions.  The system is a pump
controller that reads pressure via an ADC and uses the AVR timer to
determine a minimum run time (unless a critical pressure is reached, in
which case the timer is ignored).

Beware that when reading or writing a 16-bit timer register, it is done
in two 8-bit chunks using a hidden global hardware register that is shared
between any peripheral with 16-bit registers. Therefore, you should block
ISRs accessing any other peripheral that is likely to use this register.

I've got an LED showing me when the timer is running and another on a
solid state relay showing what the pump is supposed to be doing.
Substituting a potentiometer for the pressure transducer, I've observed
it working as planned, but sometimes the timer never expires (or won't
start) and sometimes the "virtual" pump turns on, but never off.

Having been musing about what to try to rectify this, I'll remove the
extern declarations and see if this helps.



reply via email to

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