chipKIT® Development Platform

Inspired by Arduino™

interrupts on PIC32MX250 issue

Created Tue, 03 Feb 2015 16:32:41 +0000 by GastonLagaffe


GastonLagaffe

Tue, 03 Feb 2015 16:32:41 +0000

Salut,

I am using interrupts on the PIC32MX250. Am I right that the interrrupts are locked to the pins defined in board_defs.h? I tried to map them to different pins but it looks like the attachInterrupt call maps them back.

Is there a way to use mapPPs on interrupt pins? (not urgent, as I simply explore the chip and its features)

Ciao, Mathias


majenko

Tue, 03 Feb 2015 16:37:49 +0000

Yes, attachInterrupt() performs the PPS operation.

However, there is no reason you can't do a mapPps() just after attaching the interrupt to change that mapping...


GastonLagaffe

Tue, 03 Feb 2015 17:45:28 +0000

Salut,

I tried it without succes: When I call the attachInterrupt prior to a mapPps call, neither the default pin nor the new pin triggers the ISR although mapPps returns TRUE. If I stay on the default pin, the IRS gets called on that pin

Ciao, Mathias


GastonLagaffe

Wed, 04 Feb 2015 12:48:44 +0000

Salut,

I need to correct myself, had a typo in the pinMode statement. The following code demonstrates that a mapPps call after the attachInterrupt call moves the interrupt to the new pin:

volatile uint8_t pin = 17;
uint8_t ipin = 3;
uint8_t ipin2 = 7;

void setup() {
	pinMode(pin,OUTPUT);
	pinMode(ipin, INPUT);
	pinMode(ipin2, INPUT);
//	mapPps(ipin, PPS_IN_INT1);
	attachInterrupt(1, myIsr, FALLING);
	mapPps(ipin2, PPS_IN_INT1);
}

void myIsr()
{
  digitalWrite(pin, !digitalRead(pin));	
}

void loop() {
;
}

I will now create a tutorial on interrupts. Lovely platform ... 8-)

Ciao, Mathias