Hi dear Mister_e
Thanks for your reply. Excuse me for delaying in my reply. I was too busy.
Suppose that we have this program:
Code:
'*****************************************************************
'* LCD Deifnes *
'*****************************************************************
DEFINE LCD_DREG PORTD ' I/O port where LCD is connected
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 2 ' Register select pin
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 3 ' Enable pin
DEFINE LCD_BITS 4 ' 4-bit data bus
DEFINE LCD_LINES 2 ' LCD has 2 character lines
STATE var Byte
I var Byte
PORTA = 0
PORTB = 0
'************************************************* ****************
'* Interrupt Initialzing *
'************************************************* ****************
INTCON = %10001000 ' GIE and RBIE are set
OPTION_REG = %10000000
'************************************************* ****************
'* Initialzation *
'************************************************* ****************
PORTB = 0
TRISB = %00010000
ON INTERRUPT GOTO DIRECTION
'************************************************* ****************
'* Main Program *
'************************************************* ****************
MAIN:
lcdout $fe,1,"Main Routine"
FOR I = 1 to 50 : PAUSE 10 : NEXT I ' For quick response
GOTO MAIN
END
'************************************************* ****************
'* Interrupt Service Routine *
'************************************************* ****************
DISABLE
DIRECTION:
STATE = PORTB ' End of Mismatch Condition
lcdout $fe,1
lcdout "Interrupt !!!"
IF State.4 THEN
LCDOUT $FE,$C0," LOW to HIGH "
ELSE
LCDOUT $FE,$C0, " HIGH to LOW "
ENDIF
PAUSE 100
INTCON.0 = 0
RESUME
ENABLE
END
When I want to move LCD display command out of ISR like below, the program doesn't work correctly!
Code:
'************************************************* ****************
'* Interrupt Service Routine *
'************************************************* ****************
DISABLE
DIRECTION:
STATE = PORTB ' End of Mismatch Condition
lcdout $fe,1
lcdout "Interrupt !!!"
IF State.4 THEN
GOSUB L2H
ELSE
GOSUB H2L
ENDIF
PAUSE 100
INTCON.0 = 0
RESUME
ENABLE
END
L2H:
LCDOUT $FE,$C0," LOW to HIGH "
RETURN
H2L:
LCDOUT $FE,$C0," HIGH to LOW "
RETURN
Bookmarks