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 Reply Children
  • Erik, I don't mind in another micro. Please I need an example to see how I can do it. I don't mind if this example is in another micro.

    I want to learn only learn.

    I think you could take the mickey out of me, but please don't do it. I need learn so much about electronic programming.

    Sorry if I had done something wrong.

  • general about interrupts:
    1) for external interrupts, you must use a pin designated for that purpose.
    2) you must code an ISR (interrupt service routine).
    3) you must enable the interrupt.

    in some cases:
    a) you must configure the port pin correctly for this purpose.
    b) you must set up a "crossbar" or such to route the interrupt.
    c) you must specify the priority of the interrupt. (often a default will do)

    Erik

  • Thanks a lot, Erik.

    I know I have to do all the steps you said to me, because I know the theory but I have so many problems with then practical.

    It's my first time that I use XC167 and I need some basic examples to do that.

    How can I configure whatever port pin to do whatever function when it is on or off?

  • I need some basic examples to do that

    A professional rarely can "give samples" because his code is owned by whoever paid him.

    Thus the standard reply "show your code and someone will comment on the likely cause of the problem you describe".

    Erik

  • Thanks again, Erik.

    I'd like to say that I don't want to copy any code, only have a reference, but I'm try to do you said to me.

    Thanks a lot.

  • "It's my first time that I use XC167 and I need some basic examples to do that."

    You have read the uVision Getting Started guide, haven't you?
    It contains a couple of example projects, and leads you through them.

    The Keil tools come with a whole folder full of examples: it's easy to find - it's the one named, "EXAMPLES"

    There is also a whole section of Application Notes and Examples in the Support section of this very website!

    No doubt Infineon also has a Support section to their website...

  • Thanks Andy!

    You have read the uVision Getting Started guide, haven't you?

    How can I get this guide? Do u know the link to study it?

    It contains a couple of example projects, and leads you through them.

    I'm finding it.

    The Keil tools come with a whole folder full of examples: it's easy to find - it's the one named, "EXAMPLES"

    Yes, I know that but I don't find one example to resolve my doubt :S If u can help me, please do it.


    There is also a whole section of Application Notes and Examples in the Support section of this very website!

    Can u say to me any website, please? I'm so lost.

    Thanks for all.

  • Do u know the link to study it?

    If you want micro to help you e-mail him, he does not participate in this forum.

    In any forum dealing with anything electronic, "u" is short for micro, why do you ask him, I have seen no post from him in any thread.

    Erik

  • "How can I get this guide?"

    The uVision Getting Started Guide is available on the 'Books' tab in the uVision 'Project' Window; The 'Books' window is also available via the 'Help' menu; failing all that, search for GS*.PDF in your Keil folder)

    If you have the free CD, it has some introductory videos on it showing you the way around the tools:
    https://www.keil.com/demo/cdrom.asp

    "Can u say to me any website, please? I'm so lost."

    Please stop the "u" - if you can't be bothered to type "you", you'll find people can't be bothered to help.

    When I said, "this very website" I meant this website here - the one you are currently visiting. If you look at the top of the page, you will see a blue bar with words like 'Products' and 'Support'.
    Click on 'Support' and it will take you to the Support section of this website. Then look in the left-hand column for the links to Examples and Application Notes...

    The Infineon website is http://www.infineon.com/ You should also be able to find supporting materials there.



    http://www.keil.com/books/166books.asp

  • The XC167 has many interrupts that can come from port pins and you are not limited to the fast external interrupts. You could also use the CAPCOM's as interrupts. Please be aware that when you use a fast interrupt you give up the CAPCOM interrupt for the associated channel. Given that you have asked for an example of a fast interrupt on P3.0. So here it is… You will vector to fast external interrupt 1 (EX1IN) whenever there is a change on the P3.0 that for more than two CPU clocks.

    If you did not protect the registers then you can go ahead and modify the registers directly without the unlock sequence. This code snippet is only for reference as you need to decide on the exact configuration and interrupt level you want. You are free to decide what group and level for any interrupt but make sure you make sure that they are all unique. I won't go into local and global register banks or cached interrupts since they are advance concepts.

    So to the code…

    #include <xc167.h>
    #include <intrins.h>
    
    void main(void) {
    
      EXISEL0 = 0x0020; /*input from alternate pin AltB*/
      EXICON = 0x000C; /*trigger on either edge*/
    
      /*note EX1IN uses the CC9 interrupt vector */
      CC1_CC9IC =  0x0070; /*enable the ISR and choose a group and level */
    
      PSW_IEN = 1; /*globally enable interrupts*/
    
      for(;;) {
        _nop_(); /*loop forever*/
      }
    }
    
    /*here is the interrupt entry*/
    void Ex1in_ISR (void) interrupt 0x19 {
     /*place your ISR code in here */
    }
    
    Kind regards, Chris