We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I want to work with the interrupt int0 of the FX2.
The regsiters I have to use are written down in the TRM of the FX2. But where are informations about enabling the interrupt or name of the ISR for example?
Where I can search? I only find information snippets.
Best regards Jan
When I make it static and I have included this file in both files I'll have a copy of this variable? The variable exists now two times in the stack?
But how can realize it having two files and both know this variable?
When I make it static and I have included this file in both files I'll have a copy of this variable? The variable exists now two times in the stack? 1) NO variables "exist on the stack"in C51 2) either you get an error or you have two SEPARATE variables, it is an issue of 'scope'
you need to read up on global variables and 'extern' (and header files??). Please do not respond with the usual BS about global variables.
the only way you can communicate between a function and an ISR is having them in the same module or using a global variable
Erik
And 'static' variables don't (generally?) exist on the stack anyhow!
"the only (sic) way you can communicate between a function and an ISR is having them in the same module..."
Strictly, in the same Translation Unit - in which case you'd need a variable at File Scope.
"...or using a global variable"
I guess you could also do something really horrible with absolute memory locations...
This is 'C' textbook stuff!
See: c-faq.com/.../decldef.html
Yes, but how can I realize it making it global when I use two files which have to access this variable?
could I make it as follows: creating a new file _______________________ globalVars.h:
static volatile char var;
static char getVar() { return var; }
static incVar() { var++; }
________________________
Whenn accessing the variable from the ISR or main file I call the getVar() fucntion. Does this realization create two variables internaly too?
But was it too simple to remove the "static" keyword, thereby allowing access to the variable from other translation modules?
Then a line with "extern" to tell the compiler that someone else has a variable of this type and name that it wants to share with the world.
Surely, you must realise every 'C' program with more than 1 source file must manage to do this? It really is basic, textbook stuff!
Did you actually follow the link that I provided?
Have you actually thought about the meaning of the 'static' keyword?
Problem solved. Thank you!