Page 1 of 1

scripting problrem ?

PostPosted: Tue Jan 10, 2023 4:45 pm
by alcofribas
Hi all
I'm using16F18855 because it has ADC and Timers...
My application :
Timer0 generates an IT every 100ms...
The ISR reads a potentiometer and stores the 10 bits value in a variable called A...( module Adcc.c)
So A is declared locally inside the ISR
in my main.c i declared A as extern to extend A's visibility...but, and that is my problem A is always zero, just as if A from the ISR is not A in main.c

Could someone point me to the right way to write such a small routine
thks in advance
A

Re: scripting problrem ?

PostPosted: Tue Jan 10, 2023 6:24 pm
by alcofribas
Found my bug...
Wrong place for global var...

Re: scripting problrem ?

PostPosted: Fri Jan 13, 2023 1:09 am
by ric
Indeed. The "declaration"(i.e. the line that ocntains the "extern" qualifier) belongs in a header file visible to both C files.
It must be a global variable (declared outside any function), not a local one.