Coding and general discussion relating to user created compiler modules
Moderators: David Barker, Jerry Messina
-
be80be
- Registered User
- Posts: 90
- Joined: Mon Feb 23, 2009 2:15 am
- Location: tn
Post
by be80be » Sun Mar 06, 2011 5:20 pm
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
-
Jerry Messina
- Swordfish Developer
- Posts: 1471
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Post
by Jerry Messina » Sun Mar 06, 2011 6:22 pm
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
-
be80be
- Registered User
- Posts: 90
- Joined: Mon Feb 23, 2009 2:15 am
- Location: tn
Post
by be80be » Sun Mar 06, 2011 9:42 pm
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