Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Ganged Interrupt Edge Detection (http://www.chiefdelphi.com/forums/showthread.php?t=62952)

cprogrammer 31-01-2008 13:44

Ganged Interrupt Edge Detection
 
Do Interrupts on the RB Port (Ganged Interrupts) have any edge detection registry assignments?

Kevin Watson 31-01-2008 13:53

Re: Ganged Interrupt Edge Detection
 
Quote:

Originally Posted by cprogrammer (Post 689528)
Do Interrupts on the RB Port (Ganged Interrupts) have any edge detection registry assignments?

If enabled, all four fire off on both edges. If you are interested in executing an ISR on only one edge, just examine the state of the pin in the ISR and execute your code only when it is at the right logic level (e.g., if it's a one, a rising edge just happened). If you're using my code, I pass the logic level into the ISR for you.

-Kevin

cprogrammer 31-01-2008 18:11

Re: Ganged Interrupt Edge Detection
 
Quote:

If enabled, all four fire off on both edges. If you are interested in executing an ISR on only one edge, just examine the state of the pin in the ISR and execute your code only when it is at the right logic level (e.g., if it's a one, a rising edge just happened). If you're using my code, I pass the logic level into the ISR for you.

-Kevin
How should I go about reading that logic level?
-Stephen

wt200999 31-01-2008 18:45

Re: Ganged Interrupt Edge Detection
 
Quote:

(e.g., if it's a one, a rising edge just happened)
That just means 1 or 0 basically

cprogrammer 31-01-2008 19:05

Re: Ganged Interrupt Edge Detection
 
And what registry value outputs that information?
Thanks Stephen

wt200999 31-01-2008 19:31

Re: Ganged Interrupt Edge Detection
 
if you look in the default code in the interrupt handler

Code:

  else if (INTCONbits.RBIF && INTCONbits.RBIE)  /* DIG I/O 3-6 (RB4, RB5, RB6, or RB7) changed. */
  {
    int_byte = PORTB;          /* You must read or write to PORTB */
    INTCONbits.RBIF = 0;    /*    and clear the interrupt flag        */
  }

PORTB is the register. You have to read/write to it before you can clear the flag. Have a look at how Kevin does it in his encoder code, and do you know bitwise operators and the such?

cprogrammer 31-01-2008 20:00

Re: Ganged Interrupt Edge Detection
 
Yea, but I got the impression that in his encoder code, he used the registry value to distinguish which interrupt had fired, not which edge was being detected.

wt200999 31-01-2008 20:37

Re: Ganged Interrupt Edge Detection
 
Thats where the 0 or 1 part comes into play. Take a look at the spec sheet and you will see what is in the PORTB register, and also look into bitwise operators (specifically XOR)

cprogrammer 01-02-2008 10:52

Re: Ganged Interrupt Edge Detection
 
Quote:

Encoder_3_Int_Handler(Port_B & 0x10 ? 1 : 0); // call the encoder 3 interrupt handler (in encoder.c)
I see it now, the XOR gate operator for Port_B_Delta is to distinguish which interrupt fired. Then the line of code above inputs a 0 or 1 into the function to tell whether a rising or falling edge has interrupted. Thank you for all your help wt200999


All times are GMT -5. The time now is 23:46.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi