banner



Can You Use External Interrupts And Pin Change Interrupts Within The Same Register?

litunbls

Junior Member

  • Total Posts : 107
  • Reward points : 0
  • Joined: 2016/12/28 ten:29:43
  • Location: 0
  • Status: offline

How two external interrupts tin can trigger same ISR.

Hallo,
       My PIC is dsPIC33ep512mu810.

 I want to generate an interrupt from either pivot RD7 or RD13, which should trigger an ISR.
For external interrupt, i am using INT1. But how tin can I map INT1 interrupt source to either RD7(RP71=RD7) or RD13(RPI77=RD13)?

   my code follows................................

 _TRISD6 = i;//s3 an input(ane=input, 0=output)
_TRISD13 = one;//s4 an input
ANSELD=0b1101111100111111;//s6,s7,s13 are now digital:0-Digital, 1-Analog

RPINR0bits.INT1R =0b1000111;//RP71=RD7 source of interrupt
RPINR0bits.INT1R =0b1001101;//RPI77=RD13 source of interrupt

 INTCON2bits.INT1EP = ane;//0 = Interrupt on positive border
INTCON2bits.GIE = 1;//1 = Interrupts and associated IE bits are enabled
//----------------------------------------------------------------------
IFS1bits.INT1IF = 0; /*Reset INT1 interrupt flag */
IEC1bits.INT1IE = one; /*Enable INT1 Interrupt Service Routine */
IPC5bits.INT1IP = ane; /*set depression priority*/
//---------------------------------------------------------------------

     //_INT1Interrupt() is the INT1 interrupt service routine (ISR).

 void __attribute__((__interrupt__, auto_psv)) _INT1Interrupt(void)

{
if(IFS1bits.INT1IF ==1)
{

}
}

CinziaG

die fucking humans

  • Total Posts : 3169
  • Advantage points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline

Re: How ii external interrupts tin can trigger same ISR. 2017/04/08 xiii:43:41 (permalink)

Your mapping would be expert enough, but you can have only i agile at whatsoever time - I believe, am nost sure-certain.
Is your code running? What do you see?

NorthGuy

Super Fellow member

  • Total Posts : 7177
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline

Re: How ii external interrupts can trigger same ISR. 2017/04/08 13:46:10 (permalink)

You need to apply either CN interrupt or two different INT interrupts.

du00000001

Only Some Member

  • Total Posts : 4679
  • Reward points : 0
  • Joined: 2016/05/03 thirteen:52:42
  • Location: Germany
  • Status: offline

Re: How two external interrupts can trigger same ISR. 2017/04/08 13:55:46 (permalink)

Where's the problem?
Where required' each of the ii ISRs could deliver the 'immediate ISR framework' (entry/go out code), and so calling a common subroutine.
On the vivid side: where necessary, it is easy to pass the interrupt source equally some parameter to the subroutine.

mail service edited past du00000001 - 2017/04/08 16:05:20

litunbls

Junior Member

  • Total Posts : 107
  • Advantage points : 0
  • Joined: 2016/12/28 10:29:43
  • Location: 0
  • Status: offline

Re: How 2 external interrupts can trigger same ISR. 2017/04/08 14:18:58 (permalink)

The code is running just it is taking just one external interrupt RD13.

    My idea here is to check the modify(of the signal) coming Channel A and Channel B of the encoder.
They should trigger the same interrupt service routine.
Please suggest with some code..?

CinziaG

dice fucking humans

  • Total Posts : 3169
  • Advantage points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline

Re: How 2 external interrupts can trigger same ISR. 2017/04/08 14:33:43 (permalink)

litunbls

Junior Fellow member

  • Total Posts : 107
  • Reward points : 0
  • Joined: 2016/12/28 10:29:43
  • Location: 0
  • Condition: offline

Re: How 2 external interrupts tin can trigger same ISR. 2017/04/08 15:04:09 (permalink)

CinziaG
Oh sorry, nosotros are back to the same squaregrin
http://world wide web.microchip.com/forums/m982112.aspx

  yeah...same square.sad: sad
http://www.microchip.com/forums/FindPost/347254
Can you lot delight explicate me in in a higher place link, how to assign my two digital inputs(RD7 and RD13) to create interrupt.
Delight note- I am a beginner. and Delight answer it by writing ii/3 lines of code.
I am using dsPIC33E and I could not notice the way to assign my digital inputs to Movie in the higher up method(link) which yous propose repeatedly.


PStechPaul

Super Member

  • Total Posts : 3670
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, United states of america
  • Status: offline

Re: How 2 external interrupts can trigger same ISR. 2017/04/08 fifteen:05:33 (permalink)

Something seems fishy here:

RPINR0bits.INT1R =0b1000111;//RP71=RD7 source of interrupt
RPINR0bits.INT1R =0b1001101;//RPI77=RD13 source of interrupt

 You could use 2 Schottky diodes to "OR" the low-going transitions from phase A and phase B to trigger the hardware interrupt, and and then read digital inputs to see if the change was A or B. Might also need a capacitor or ii as transition detectors. But if the inputs can be configured for IOC, the hardware interrupt pins would not be needed.

MBedder

Circuit breaker

  • Total Posts : 7064
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Condition: offline

Re: How 2 external interrupts can trigger aforementioned ISR. 2017/04/08 16:47:34 (permalink)

It is absolutely normal and prophylactic to map more than one RPn pins to the same INTx input. So no Shottky-shmottky is needed at all.

NorthGuy

Super Member

  • Full Posts : 7177
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline

Re: How ii external interrupts tin can trigger same ISR. 2017/04/08 17:24:54 (permalink)

MBedder
Information technology is absolutely normal and safe to map more i RPn pins to the aforementioned INTx input.

 Not really. Yous can connect multiple INTs to a single input, but you cannot drive the same INT with multiple pins at the aforementioned time.

CinziaG

die fucking humans

  • Total Posts : 3169
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline

Re: How 2 external interrupts tin can trigger same ISR. 2017/04/09 01:21:44 (permalink)

Interesting. Well, allow me know when you discover the truth grin

Gort2015

Klaatu Barada Nikto

  • Total Posts : 5474
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: online

Re: How ii external interrupts tin trigger same ISR. 2017/04/13 05:43:10 (permalink)

"Channel A and Aqueduct B of the encoder."

 If this is a rotary encoder, you but need ane irq for the clock.
Read B for the change from last to get the direction.

 I use Change Notify.

vjasinski

Super Member

  • Full Posts : 159
  • Reward points : 0
  • Joined: 2013/04/xxx 11:48:06
  • Location: Michigan, Us
  • Condition: offline

Re: How 2 external interrupts can trigger aforementioned ISR. 2017/04/13 05:57:36 (permalink)

From the spec sheet (dsPIC33EPXXX(GP/MC/MU)806/810/814 and PIC24EPXXX(GP/GU)810/814):
2: Every I/O port pin (RAx-RGx) can be used as modify notification (CNAx-CNGx). Run into Section xi.0 "I/O Ports" for more data.
Employ the change notification interrupt for each input. Then test the A/B inputs inside the CNInterrupt routine. Decode every bit has been explained in many references pointed out here.
Vince

Can You Use External Interrupts And Pin Change Interrupts Within The Same Register?,

Source: https://www.microchip.com/forums/m984880.aspx

Posted by: martinezshough.blogspot.com

0 Response to "Can You Use External Interrupts And Pin Change Interrupts Within The Same Register?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel