| |
SPL GPIO InterruptPort programming - How to start GPIO InterruptPort programming
1. Add "InterruptPort" command
- Double click "InterruptPort" item on the tree.
| |
InterruptPort port7
/Pin:7
/GlitchFilter:false
/ResistorMode:PullDown
/InterruptMode:InterruptEdgeBoth
| |
|
- You can change Pin number as one of between 5 ~ 10.
- You can change GlitchFilter as true.
- You can change ResistorMode as one of among the "PullUp, PullDown, and Disabled".
- You can change InterruptMode as one of among the "InterruptEdgeBoth, InterruptEdgeHigh, InterruptEdgeLevelHigh, InterruptEdgeLevelLow, InterruptEdgeLow, and InterruptNone".
|
|
|
2. Assign procedure name for the interrupt event
- Interrupt port is almost same with input port except it provides intterrupt event.
- Interrupt port generate event when its port state is changed.
- You can use this event by assign correspond procedure on the "/Procedure_OnInterrupt:" option.
- Double-click "/Procedure_OnInterrupt:" option from the tree and type "proc1" as a target procedure name.
| |
InterruptPort port7
/Pin:7
/GlitchFilter:false
/ResistorMode:PullDown
/InterruptMode:InterruptEdgeBoth
/Procedure_OnInterrupt:proc1
| |
|
3. Add procedure lines to process interrupt event
- When interrupt event is occured, SPL engine transfer its event value as a local variable named "value".
- When you create procedure script, you can reference these values.
- Add procedure script to process interrupt event as follows.
| |
InterruptPort port7
/Pin:7
/GlitchFilter:false
/ResistorMode:PullDown
/InterruptMode:InterruptEdgeBoth
/Procedure_OnInterrupt:proc1
procedure proc1
print "Changed Pin: " + value.Pin
print "New state: " + value.State
end
| |
|
4. Re-launch SPL emulator
- if SPL emulator is running, please terminate emulator.
- Press "F5" key to re-launch SPL emulator on the editor.
5. Send SPL script to emulator
- Click "Send Script" button to send SPL script to emulator
- Executed result will be shown as follows.
|