Hi all,
Thanks Mel for looking. LCD is on PORTD.4 - PORTD.7 (MSSP turned OFF) RS/EN on PORTC 4, 5. So no sources of interrupt from there. Also as Darrel mentioned that LCD is a synchronous interface it should not matter much.
If I am using some of your routines or macro or I2 (I.square a.k.a Instant Interrupt) and find that it is using the PBP macro for checking page or resetting to page zero then I use that. If I am using my own ISR I use banksel. Is this wrong ??
Darrel I have never bothered how the data is actually transported to the LCD. I am studying now. Can there be issues if the timing between two nibbles get spoiled for the program doing too much in Interrupt.
I am re-structuring the code and would post it here. Also I would use LCDs from different brands and see if this cheap Chinese LCD (In fact all that are available are Chinese) is a culprit.
BTW I noticed that PBP sets the PINs as output every time LCDOUT is used. Was my observation correct. Can this be safely removed as I have manually set it as output and never use the LCDIN command in my prog.
Regards
Sougata
Regards
Sougata
I can try ...
I guess the biggest problem is with CHK?RP and RST?RP.
Each time they're used, it saves it's result to an ASM variable called PREV_BANK.
And the next time one's used, CHK?RP uses that PREV_BANK value to figure out if it needs to change the bank ... and if so ... which bits need to be set to use the least amount of code space.
Using BANKSEL or setting the bank manually does not update the PREV_BANK variable, so PBP can get lost from not knowing which bank it's really in.
Even GOTO's within an area of code that only uses CHK?RP can be problems.
For instance with this code ...PREV_BANK works line by line from the top of the program.Code:MyVar0 VAR BYTE BANK0 MyVar1 VAR BYTE BANK1 ASM CHK?RP _MyVar1 ; 1 - this will select BANK1 movlw 12 xorwf _MyVar1,W btfss STATUS,Z goto Bypass CHK?RP _MyVar0 ; 2 - this selects BANK0 btfss _MyVar0,5 goto ExitRoutine Bypass CHK?RP _MyVar0 ; 3 - This statement does nothing. Although the intent movlw 34 ; was to change to BANK0, the PREV_BANK from the movwf _MyVar0 ; last CHK?RP at step 2 says we're already in BANK0. goto AnotherPlace ; But if we got here from the goto Bypass in step 1 ... ; then BANK1 is still selected, and it will overwrite ; the wrong RAM location in BANK1. ExitRoutine ENDASM
GOTO's can bypass that logic.
There are many different variations of the same problem, and BANKSEL or manually setting STATUS or BSR bits will only make it worse.
Once you know how it works ... of course ... it's a piece of cake.
Some of the ways around the problems are to use the LABEL?L, L?GOTO and L?CALL macros.
<br>
Clear as MUD.
DT
Thanks for the explanation.
Using CHK?RP messes with the PREV_BANK variable. So if I use Banksel in my ASM routine (not within the main body of the program but ISR) would there be any problem ? If yes, then why ? Context is being restored automatically either through the shadow registers for High Priority or through your program if LP is used.
Regards
Sougata
Context/Shadow registers will ensure that when it returns from the interrupt ... those 3 register sets will have the same contents in them.
But if values get written to the wrong BANK somewhere within the ISR, shadow registers can't help.
It's especially important to maintain the proper PREV_BANK when using ASM in the Main program, since there are no Shadow registers to get everything back to normal when it's finished.
And ALL ASM routines in the Main program that use any PBP macros like CHK?RP, RST?RP, MOVE?xx with other bank switching methods, should end with ...Which resets PBP's banking system in preparation for the next statement.Code:; for 16F's ... clrf STATUS PREV_BANK = 0 ; for 18F's clrf BSR PREV_BANK = 0
<br>
DT
Sougata,
Just curious, are you using PBP 2.6 ?
Dave
Always wear safety glasses while programming.
Bookmarks