GPIO Interrupt port programming


1. Add GPIO Interrupt port
  1. Use "InterruptPort" command to add new GPIO interrupt port.

  2. Select "Application" tab.

  3. 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
    
      
 

  1. Click "Send to MF Application" button or Press "F5" key.

  2. Executed result:




2. Read state of GPIO port by using "Read()" method
  1. Use "Read()" method to read current state.

  2. Type below script on the editor to read Pin 7's state.

      
    state = port7.Read()
    
    print "State of Pin7 is " + state
    
      


  3. Click "Send to MF Application" button or Press "F5" key.

  4. Executed result:




3. Event procedure of interrupt port
  1. Interrupt port has event procedure which raises event when its state is changed.

  2. In order to raise event for interrupt port, you have to use emulator script.

  3. Select Emulator tab as follow.



  4. Type below script on the emulator's editor in order to change the state of interrupt port.

      
    port7.Write(true)
    
      


  5. Click "Execute Script on the Emulator" button or Press "F5" key.



  6. Executed result:



  7. You can see the log message that Port7's state was set with true.

  8. Also, you will see the console message of application which was generated from your "myProcedure1".