Yes it's possible... case by case, just post your code here, tell us what you want to do, and we will be able to tell you better.
Yes it's possible... case by case, just post your code here, tell us what you want to do, and we will be able to tell you better.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
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:
When I want to move LCD display command out of ISR like below, the program doesn't work correctly!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
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
Just like with the ISR itself, ... any subroutines jumped to from the ISR must be DISABLED from further interrupts, or they will attempt to interrupt themselves.
Moving the ENABLE line to after the H2L: subroutine should help.
<br>
DT
Thanks alot
Last edited by yasser hassani; - 2nd May 2008 at 12:26.
Thanks Dear Taylor
If you see the first program you'll find out infact your suggestion (Moving the ENABLE line to after the H2L: subroutine should help) is used at it. My problem is about second program.
Suppose that I want to implement this:
When H2L occures, the program should start displaying contents of EEPROM (We call Address). Address increments one by one till interrupt L2H occures. Now program should start displaying Address again but in this subroutine Address decrements one by one. How can I do that?
Please help me.
Thanks alot.
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
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Thanks dear Acetronics. OK. I should explain more about my problem. Suppose that I want to read EEPROM from 0000h-05DCh. Variable Add refers to address of place that should be read and displayed on LCD. When L2H interrupt occures, program starts displaying Add on LCD. Add increments one by one. If H2L interrupt doesn't occure Add rolles over and initialize with 0000. When H2L interrupt occures program should start displaing Add and decrement it one by one. For example if Add=100 and H2L occures, program starts displaying from 100 and decrement it. Suppose that Add reaches to 0000 and L2H interrupt doesn't occure. In this case program should initialize Add with 05DCh and decrement it one by one.
Thanks again for your attention. I wait for your suggestions.
----
Regards
Hi, Yasser
Ok, I begin to see ...
How much time do the addresses contents have to be displayed on your LCD before displayin the next adress content ??? ( pause between EEPROM address increments )
I begin to doubt seriously you need any kind of interrupt ( for the part we know ... of course)
By the way ... which processor and memory do you use ???
Alain
PS: I had a moment and Threw that on the screen ...
- Compiles Ok
- But not tested ... the idea is here
NO INTERRUPT !!!
Re PS: Compiled AND Tested ...
Code:' Processor 16F877a @ 4Mhz 'Yasser's light or text show '***************************************************************************** '***************************************************************************** ' IMPORTANT NOTE '***************************************************************************** '***************************************************************************** ' ' The 16F877a shows only 256 EEPROM Bytes ... ' ' DO NOT ASK IT 1500 !!! '***************************************************************************** '***************************************************************************** '***************************************************************************** '* LCD Defines for EasyPic5 * '***************************************************************************** ' DEFINE LCD_DREG PORTB ' I/O port where LCD is connected ' DEFINE LCD_DBIT 0 ' DEFINE LCD_RSREG PORTB ' DEFINE LCD_RSBIT 4 ' Register select pin ' DEFINE LCD_EREG PORTB ' DEFINE LCD_EBIT 5 ' Enable pin ' DEFINE LCD_BITS 4 ' 4-bit data bus ' DEFINE LCD_LINES 2 ' LCD has 2 character lines ' DEFINE OSC 8 '***************************************************************************** '* LCD Defines * '****************************************************************************** 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 '***************************************************************************** 'Chip initialization ADCON0 = 0 ADCON1 = 7 CMCON = 7 CVRCON = 0 '***************************************************************************** 'Variables & aliases ' Scroll var PORTA.0 ' Start and Scroll up/dn button Scroll var PORTB.4 ' Start and Scroll up/dn button Index var Word I var Word Delay var Byte Value var Byte Cold var Bit 'Variables initialization CLEAR Cold = 1 '***************************************************************************** 'Constants Endaddress CON $FF' 05DC 'Memory last address to read ScrollPause CON 400 'ReadPause duration in ms '***************************************************************************** 'PORTS Initialization PORTA = 0 PORTB = 0 PORTC = 0 PORTD = 0 PORTE = 0 TRISA = 0 TRISB = %00010000 TRISC = 0 TRISD = 0 '***************************************************************************** 'LCD Initialization LCDOUT $FE,1 'Clearscreen PAUSE 700 '***************************************************************************** '***************************************************************************** Coldstart: Delay = 0 BUTTON Scroll,1,255,0,delay,1,Released IF cold THEN LCDOUT $FE,$80," Hello Yasser " ' Waiting Message LCDOUT $FE,$C0,"Waiting for you" cold = 0 ENDIF goto ColdStart Released: Delay = 0 BUTTON Scroll,1,255,0,delay,1, Released ' Wait for button release LCDOUT $FE,1 'Clear Screen Increase: Index = I FOR I = Index to (Endaddress - 1) Step 2 READ I,Value LCDOUT $FE,$80, BIN8 Value," ",DEC3 I 'BIN8 for Binary, may be decimal or character READ I+1,Value LCDOUT $FE,$C0, BIN8 Value," ",DEC3 I+1 PAUSE ScrollPause Delay = 0 BUTTON Scroll,1,255,0,delay,1,Decrease 'Reverse Scrolling requested ? NEXT I I = 0 'No toggle ... let's rewind Index = 0 Goto Increase Decrease: Index = I FOR I = Index to 1 Step - 2 READ I,Value LCDOUT $FE,$80, BIN8 Value," ",DEC3 I 'BIN8 for Binary, may be decimal or character READ I+1,Value LCDOUT $FE,$C0, BIN8 Value," ",DEC3 I+1 PAUSE ScrollPause Delay = 0 BUTTON Scroll,1,255,0,delay,0,Increase 'Continue Reverse scrolling ? NEXT I I = EndAddress -1 'No toggle ...let's rewind Index = Endaddress Goto Decrease END
Last edited by Acetronics2; - 4th May 2008 at 18:36. Reason: a little mismatch between I and Index ... LOL !!!
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
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
Bookmarks