| |
GPIO Interrupt port programming
1. Add GPIO Interrupt port
- Use "InterruptPort" command to add new GPIO interrupt port.
- Select "Application" tab.
- Add a new GPIO Interrupt port as follows.
| |
clear
InterruptPort port7
/Pin:7
/GlitchFilter:false
/ResistorMode:PullDown
/InterruptMode:InterruptEdgeBoth
/Procedure_OnInterrupt:myProcedure1
procedure myProcedure1
pin = value.Pin
state = value.State
print "Pin: " + pin + " / State: " + state
end
| |
|
|
|
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
2. Read state of GPIO port by using "Read()" method
- Use "Read()" method to read current state.
- Type below script on the editor to read Pin 7's state.
| |
state = port7.Read()
print "State of Pin7 is " + state
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
3. Event procedure of interrupt port
- Interrupt port has event procedure which raises event when its state is changed.
- In order to raise event for interrupt port, you have to use emulator script.
- Select Emulator tab as follow.
- Type below script on the emulator's editor in order to change the state of interrupt port.
- Click "Execute Script on the Emulator" button or Press "F5" key.
- Executed result:
- You can see the log message that Port7's state was set with true.
- Also, you will see the console message of application which was generated from your "myProcedure1".
|