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
  • "Hello, I need to know the exact moment when an input is set."

    To do this you either need to use some means of generating an interrupt based on the input or you need to poll the input very quickly.

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

    If you can guarantee that the signal generating the interrupt will remain active for greater than the latency period you can 'OR' several signals together on one interrupt pin and connect each one to a port pin. In the ISR you then poll each pin to see which one generated the interrupt. Alternatively you might look at using an external interrupt controller IC.

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

    Only you can make that decision.

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

    To do this you either need to use some means of generating an interrupt based on the input or you need to poll the input very quickly.

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

    If you can guarantee that the signal generating the interrupt will remain active for greater than the latency period you can 'OR' several signals together on one interrupt pin and connect each one to a port pin. In the ISR you then poll each pin to see which one generated the interrupt. Alternatively you might look at using an external interrupt controller IC.

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

    Only you can make that decision.

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

  • "If you can guarantee that the signal generating the interrupt will remain active for greater than the latency period you can 'OR' several signals together on one interrupt pin and connect each one to a port pin. In the ISR you then poll each pin to see which one generated the interrupt. Alternatively you might look at using an external interrupt controller IC."

    Have u got a sample code for that?

    How can I use ISR? How can I connect several signal together on 1 interrupt pint? I'm so lost. Please, help me.

  • another approach:
    Often I use more than one micro (you can get flash based micros for about $0.50) and have found that often the best way to handle a problem is to "divide and conquer".

    Erik

  • "Have u got a sample code for that?"

    I'm afraid it's your job to write the code.

    "How can I use ISR? How can I connect several signal together on 1 interrupt pint? I'm so lost. Please, help me."

    It sounds like you don't have much idea about electronics or programming. I think you will have to go back and learn the basics before you can tackle this kind of project.

  • Have u got a sample code for that
    does micro not have an e-mail account, it seems this forum is becoming his mailbox

  • I want to learn more, but how can I do it?

    I want to be an expert. Please, help me and say to me what can I read about this.

    Thanks and sorry if my mails can disturb you.

  • I want to be an expert.
    an honorable ambition.

    Please, help me and say to me what can I read about this.
    since some approaches has been suggested (Stefan made one, I made another) it would be nice to know what "this" is.

    Thanks and sorry if my mails can disturb you
    refrain form the Stupid Monkey S*** and nothing in your posts "disturb" me.

    Erik

    Note
    This message was edited because of rude or abusive language.

  • an addition

    I want to be an expert.
    an honorable ambition

    but remember TTT http://www.geocities.com/dnehen/soma/hein.htm

    Erik

  • I have seen an example about interrupt but I don't know now where it is.

    I need a example to make an interrupt when bit 0 of port 3 is set.

    Can u help me?