This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

fx2 interrupt int0

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

Parents Reply Children
  • 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...

  • the only way you can communicate between a function and an ISR is having them in the same module or using a global variable

    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?