PCintPort operation [RESOLVED]

Dear community,

I would like to attach an Interrupt to the Pin 10. So I will use the external interrupt library "PCintPort".

If I’m not mistaken, the ISR corresponding to « PCInt0 » is triggered by each change on Pins from 8 to 13, whatever the declared Pin in PCintPort::attachInterrupt(). Then, the dicrimination for a change on the declared Pin is ensured by the PCintPort library.

My question :
I run a PWM on the Pin 9, so a lot of change from HIGHT to LOW per second !

-> Is the ISR is triggered by a PIN declared in OUTPUT mode ? So is the ISR will be triggered by my PWM ?

If yes, I’m affraid that this interrupt induce a terrible mess in my loop !!

Thanks

Méric.

Have you tried? best way to find out is to do it!

PCints 0, 1, 2 are for ports B, C and D respectively, so yes PCint0 will do port B (pins 8 to 13).

Yes, the interrupts respond to the voltage on the pin, irrespective of whether the pin is input,
output or PWM or anything. But if you mask out that pin, it won't trigger interrupts.

Thank you Mark.
Mask it ? How can I do that ?

Meric:
Thank you Mark.
Mask it ? How can I do that ?

All are masked by default, the library you use probably takes care of this.

If not its useful to read the section in the datasheet about pin-change interrupts where all is
explained.

See here:

Following Mark advice, I RTFM, chapt 13.

What I understood

  • Since the External Interrupt is set up, the µctrl check all the relevant Pins, at each Clock beat.
  • Depending of the toggled Pin and the applicable Mask, it raise the corresponding ISR or not.

So, the check on all the Pins is anyway performed, whatever the change on it, even a frenetic change like a PWM.

  • When using an External interrupt on a PWM, the µctrl just notice a lot of change.
  • The only risk is the time to read the mask.

Personally, I'll base my architecture on this feasibility assumption, I will now follow JML recom to just do it.
I’ll come back to you if I encounter any surprise.

Thx to all.

Méric.

Meric:
Following Mark advice, I
So, the check on all the Pins is anyway performed, whatever the change on it, even a frenetic change like a PWM.

You can say it this way. But it is hardware outside CPU who is checking the pins. Only when unmasked pin is changed the CPU is informed. You should notice no difference in program behavior with any signal applied on masked pin. It does not make anything slower or take considerably more power.