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

Interrupts, flags and functions

Hello, I need to know the exact moment when an input is set.

I'm using XC167CI and I have fast interrupts. This way is full, I mean I have used all fast interrupts.

I don't know how I can know when an input por is set and reset.

What can I do? I which file can I paste the code? Maybe in MAIN.C? Maybe in IO.C?

Please, help me.

Parents
  • Thanks a lot, Stefan.

    But I mean I have several inputs and in whatever moment this input can be set by an external machine, for example.

    I know what I have to do when this input is set or reset (if I don't know it maybe I have to leave my job :S), but my exactly problem is where I can paste the code. In Main.C?

    I don't know if my argue is good. I only want to do where I can write the function to do something when whatever input is set or reset.

    In the post before I said that I have used all my fast interrupt. I know the exact place where my code have to be.

    Another question:

    In my MAIN.C I have a while loop

     while (1) {
    
    }

    Some people and the mayority examples that I have seen put this while in MAIN.C. I think it is necessary because the microcontroller have to wait inputs to do what it has to do. So if I paste my code, for example:

     if (P3_P0) {
      /* if P3.0 is set I have to set the out P6.2 or I have to call doSomething() functions.
    */
    }
    inside this loop I have another problem because the microcontroller always calls doSomething function.

    I think I need a flag but I don't have a example for that. If someone can help me, please do it.

Reply
  • Thanks a lot, Stefan.

    But I mean I have several inputs and in whatever moment this input can be set by an external machine, for example.

    I know what I have to do when this input is set or reset (if I don't know it maybe I have to leave my job :S), but my exactly problem is where I can paste the code. In Main.C?

    I don't know if my argue is good. I only want to do where I can write the function to do something when whatever input is set or reset.

    In the post before I said that I have used all my fast interrupt. I know the exact place where my code have to be.

    Another question:

    In my MAIN.C I have a while loop

     while (1) {
    
    }

    Some people and the mayority examples that I have seen put this while in MAIN.C. I think it is necessary because the microcontroller have to wait inputs to do what it has to do. So if I paste my code, for example:

     if (P3_P0) {
      /* if P3.0 is set I have to set the out P6.2 or I have to call doSomething() functions.
    */
    }
    inside this loop I have another problem because the microcontroller always calls doSomething function.

    I think I need a flag but I don't have a example for that. If someone can help me, please do it.

Children