Page 1 of 1

ISROnChange as a flag to change port pin output

Posted: Sun Mar 06, 2011 5:20 pm
by be80be
I was trying to use a event handler to change the bit of to "action = 1"
Which works but i can't reset it to 0


Code: Select all

Device = 18F1220
Clock = 8
 
Config MCLRE = OFF                      'Disable MCLR on Pin 4 (RA5)
 
// import modules...
Include "ISROnChange.bas"
Include "Utils.bas"
Dim action As Bit

// event handler...
Event OnChange()
   action = 1
   
End Event

// program start...
SetAllDigital
SetRBMask($80)                      // only interested in PORTB.7 on change events
ISROnChange.Initialize(OnChange)    // initialize the OnChange module, pass OnChange event handler
 action = 0
// loop forever...
While true
       action = 0
      If action = 1 Then
      High (PORTA.0)
      DelayMS(1000)
      
      ElseIf action = 0 Then
       Low (PORTA.0)
      EndIf
Wend

Posted: Sun Mar 06, 2011 6:22 pm
by Jerry Messina
If you've got the interrupts set up and working properly, instead of always clearing Action every time through the loop, try

Code: Select all

While true
    If action = 1 Then
        action = 0          // only clear action if set by event
        High (PORTA.0)
        DelayMS(1000)
    ElseIf action = 0 Then
        Low (PORTA.0)
    EndIf
Wend

Posted: Sun Mar 06, 2011 9:42 pm
by be80be
Jerry the key word was if LOL I had the
interrupts set up and working properly
I had that right

I forgot to set the dang osscon to $72 it was changing about 20 minutes later LOL

Thanks Jerry