Hi
On this example from you (original) about IOC,
the interrupt macro is identifying on which pin the interrupt occurred by testing which portB bit changed.
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).
Interrupt On Change ( IOC ) identifying by reading Flag
-
- 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
Many thanks in advance,
Miguel Garcia,
Electronic Systems Developer
-
- Matrix Staff
- Posts: 1922
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: Interrupt On Change ( IOC ) identifying by reading Flag
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.
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 261 times
Martin
-
- Matrix Staff
- Posts: 1922
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: Interrupt On Change ( IOC ) identifying by reading Flag
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.
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
Re: Interrupt On Change ( IOC ) identifying by reading Flag
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 ?
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
-
- Matrix Staff
- Posts: 1922
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: Interrupt On Change ( IOC ) identifying by reading Flag
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.
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