SPL GPIO InterruptPort programming - How to start GPIO InterruptPort programming


1. Add "InterruptPort" command
  1. Double click "InterruptPort" item on the tree.



      
    InterruptPort    port7
    	/Pin:7
    	/GlitchFilter:false
    	/ResistorMode:PullDown
    	/InterruptMode:InterruptEdgeBoth
    
      


  2. You can change Pin number as one of between 5 ~ 10.

  3. You can change GlitchFilter as true.

  4. You can change ResistorMode as one of among the "PullUp, PullDown, and Disabled".

  5. You can change InterruptMode as one of among the "InterruptEdgeBoth, InterruptEdgeHigh, InterruptEdgeLevelHigh, InterruptEdgeLevelLow, InterruptEdgeLow, and InterruptNone".
 



2. Assign procedure name for the interrupt event
  1. Interrupt port is almost same with input port except it provides intterrupt event.

  2. Interrupt port generate event when its port state is changed.

  3. You can use this event by assign correspond procedure on the "/Procedure_OnInterrupt:" option.

  4. 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
  1. When interrupt event is occured, SPL engine transfer its event value as a local variable named "value".

  2. When you create procedure script, you can reference these values.



  3. 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
  1. if SPL emulator is running, please terminate emulator.

  2. Press "F5" key to re-launch SPL emulator on the editor.




5. Send SPL script to emulator
  1. Click "Send Script" button to send SPL script to emulator



  2. Executed result will be shown as follows.