mesamune80
New Member
Hi all,
i had figuring this thing since last week, but i still not manage to find out what is the cause of this problem.............i also using the button debouce to detect my button.
Below is the code:
ADCON1 = 7 '%10001000 'A4-7 analog RA3 +Vref RA2 -Vref
TRISA = %11111111
TRISB = %00000001
TRISC = %11100000
TRISD = %11100011
OPTION_REG.6 = 1 'RB0/INT edge triggered (rising edge)
OPTION_REG.7 = 1 'weak pull up disable.
INTCON = %10010000
'Button debouce routine
If PORTA.0 = 0 Then Goto press 'button debounce checking..
press:
Disable' disable all unmask interrup
While PORTA.0 = 1
delay = 20
WaitMs delay
Wend
While PORTA.0 = 0 And delay <> 0
delay = delay - 1
Wend
If delay <> 0 Then
Goto loop2
Else
Goto release
Endif
release:
Disable
While PORTA.0 = 0
delay = 20
WaitMs delay
Wend
While PORTA.0 = 1 And delay <> 0
delay = delay - 1
Wend
If delay <> 0 Then
Goto release
Else
Goto m1
Endif
m1:
High PORTC.5 'my solenoid output..
WaitMs 500
Enable 'enable all unmask interrupt
While PORTC.6 <> 0
dir1 = 1 'CW DOWN
High PORTC.0 'pulse port for m1
WaitMs 1
Low PORTC.0
WaitMs 1
'count1 = count1 + 1
Wend
On Interrupt "My ISR
If INTCON.INTF = 1 Then 'RB0 External interrupt flag bit=1 (external interrupt occured)
INTCON.INTF = 0
Goto init
'Goto loop
Endif
'INTCON = %10010000 'renable RB0 interrupt and all unmask interrupt.
Resume
____________________________________________________________________________
ok this is the problem i am facing now....
the RB0 interrupt automatically executed although the interrupt button is not press.....>.<"
so everytime the program come to enable it automatically go to interrupt service routine.Anyone know what is the cause of this?
Thanks for all your help and guidance.
i had figuring this thing since last week, but i still not manage to find out what is the cause of this problem.............i also using the button debouce to detect my button.
Below is the code:
ADCON1 = 7 '%10001000 'A4-7 analog RA3 +Vref RA2 -Vref
TRISA = %11111111
TRISB = %00000001
TRISC = %11100000
TRISD = %11100011
OPTION_REG.6 = 1 'RB0/INT edge triggered (rising edge)
OPTION_REG.7 = 1 'weak pull up disable.
INTCON = %10010000
'Button debouce routine
If PORTA.0 = 0 Then Goto press 'button debounce checking..
press:
Disable' disable all unmask interrup
While PORTA.0 = 1
delay = 20
WaitMs delay
Wend
While PORTA.0 = 0 And delay <> 0
delay = delay - 1
Wend
If delay <> 0 Then
Goto loop2
Else
Goto release
Endif
release:
Disable
While PORTA.0 = 0
delay = 20
WaitMs delay
Wend
While PORTA.0 = 1 And delay <> 0
delay = delay - 1
Wend
If delay <> 0 Then
Goto release
Else
Goto m1
Endif
m1:
High PORTC.5 'my solenoid output..
WaitMs 500
Enable 'enable all unmask interrupt
While PORTC.6 <> 0
dir1 = 1 'CW DOWN
High PORTC.0 'pulse port for m1
WaitMs 1
Low PORTC.0
WaitMs 1
'count1 = count1 + 1
Wend
On Interrupt "My ISR
If INTCON.INTF = 1 Then 'RB0 External interrupt flag bit=1 (external interrupt occured)
INTCON.INTF = 0
Goto init
'Goto loop
Endif
'INTCON = %10010000 'renable RB0 interrupt and all unmask interrupt.
Resume
____________________________________________________________________________
ok this is the problem i am facing now....
the RB0 interrupt automatically executed although the interrupt button is not press.....>.<"
so everytime the program come to enable it automatically go to interrupt service routine.Anyone know what is the cause of this?
Thanks for all your help and guidance.
Last edited: