My Code and Jump from ISR
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
Expressing the "problem" is half way to solve it ...
Hi, Yasser
From reading your posts, I understand you want to scan your EEPROM, increasing address way, on a PORTB.4 H to L transition and decreasing addresses on a L to H transition ...
Ok ...
just use a FOR - NEXT EEPROM reading loop in the main program , if a "H2L" flag is set and a FOR-NEXT-STEP-1 EEPROM loop if a "L2H" flag is set.
Note I use 2 flags to let the initial "no transition" condition usable for something Else...
The ONLY questions will be : do you want to toggle reading order if EEPROM reading is not complete ???
What will you do when EEPROM reading is complete ??? ( seems you wait for further transition ... )
This has a strange smell of "K2000 scanner" or scrolling device ... really don't know why ... LOL !
Alain
Reading from serial eeprom
Hi dear Acentronics.
Thank you very much for your helpful program. Sorry for my delay!! I found out I can write program without interrupt. I simulated your program with proteus. It worked correct.
I want to use PIC16F877.
I know that micro's eeprom hasn't 1500b memory.
You know, I want to use serial eeprom for example 24c04 (4K bit)
Can you help me about changes on your written program for using serial eeprom ?
I think that I should use i2cread command like below:
i2cread sda , scl , ctw , I , Value
==================
Again more and more thanks.
Regards