Interrupt On Change ( IOC ) identifying by reading Flag

For general Flowcode discussion that does not belong in the other sections.
Post Reply
miggarc
Posts: 52
http://meble-kuchenne.info.pl
Joined: Mon Jan 04, 2021 8:08 pm
Has thanked: 7 times
Been thanked: 4 times

Interrupt On Change ( IOC ) identifying by reading Flag

Post by miggarc »

Hi

On this example from you (original) about IOC,

InterruptOnChange_Pulse_Counter.fcfx
(15.3 KiB) Downloaded 46 times

the interrupt macro is identifying on which pin the interrupt occurred by testing which portB bit changed.

1.jpg
1.jpg (37.91 KiB) Viewed 1559 times

Can't we do the same simply by reading the correspondents IOC Flags :
IOCBF7 , IOCBF6 , IOCBF5 , IOCBF4


By the way, if I want to do that, how do I read those flags in flowcode.
(if this implies C code portion, please give me an example of it).

Many thanks in advance,


Miguel Garcia,
Electronic Systems Developer

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: Interrupt On Change ( IOC ) identifying by reading Flag

Post by medelec35 »

Hello.
Attached is one way you can do it by reading the interrupt flags.
I have changed the interrupt properties to set the flags for rising edge only.
Note that more than one switch press detection could occur due to contact bounce.
That can easily by fixed if required.
Attachments
InterruptOnChange_Pulse_Counter v2.fcfx
(14.26 KiB) Downloaded 51 times
Martin

miggarc
Posts: 52
Joined: Mon Jan 04, 2021 8:08 pm
Has thanked: 7 times
Been thanked: 4 times

Re: Interrupt On Change ( IOC ) identifying by reading Flag

Post by miggarc »

Hi

A meda some changes but it doesn't work.

Can you please take a look ?

InterruptOnChange_Pulse_Counter v2_a.fcfx
(16.68 KiB) Downloaded 51 times

Many thanks in advance,


Miguel Garcia,
Electronic Systems Developer

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: Interrupt On Change ( IOC ) identifying by reading Flag

Post by medelec35 »

Hi.
In what way is not working simulation or hardware or both?
I Should have stated that it will not work with simulation, it will only work on hardware.
Also, with the 16F1937 you can use pins 0 to 7.
You are not restricted to pins 4 to 7, like you are with the more older devices.
Personally, if you want it to work with simulation and hardware then I would use the flowchart you posted in the very first post.
At least then it will work with other target devices.
There is a risk that if you change your target device then the flowchart with the C code might not work as the register names could of changed.
Martin

miggarc
Posts: 52
Joined: Mon Jan 04, 2021 8:08 pm
Has thanked: 7 times
Been thanked: 4 times

Re: Interrupt On Change ( IOC ) identifying by reading Flag

Post by miggarc »

Hi

Only on FC simulation it wasn't working.
On correspondent hardware it was working correctly .

Is there any other way to identify IOC changed pin by reading its correspondent Flag, that can also be FC simulated ?

Many thanks in advance,


Miguel Garcia,
Electronic Systems Developer

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: Interrupt On Change ( IOC ) identifying by reading Flag

Post by medelec35 »

Although there is some C code that can be simulated, registers can not.
As I stated in my previous post, Flowcode can simulate by using the first flowchart you posted.
The port will need to be read within the interrupt, then check to see what has been changed.
Martin

miggarc
Posts: 52
Joined: Mon Jan 04, 2021 8:08 pm
Has thanked: 7 times
Been thanked: 4 times

Re: Interrupt On Change ( IOC ) identifying by reading Flag

Post by miggarc »

Hi

Many thanks in advance,


Miguel Garcia,
Electronic Systems Developer

Post Reply