Go Down

Topic: PCintPort operation [RESOLVED] (Read 200 times) previous topic - next topic

Meric

Aug 12, 2017, 06:43 pm Last Edit: Aug 13, 2017, 03:43 pm by Meric
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.

J-M-L

Have you tried? best way to find out is to do it!
Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums
Pas de messages privés SVP

MarkT

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.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Meric

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


Smajdalf

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

All are masked by default, the library you use probably takes care of this.
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

MarkT

If not its useful to read the section in the datasheet about pin-change interrupts where all is
explained.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

larryd

No technical PMs.
The last thing you did is where you should start looking.

Meric

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.

Smajdalf

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.
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

Go Up