OHH, great idea!! Thanks Dave, I will try this now.
So sad, got an error : Bad BANK number
OHH, great idea!! Thanks Dave, I will try this now.
So sad, got an error : Bad BANK number
Last edited by cncmachineguy; - 21st December 2010 at 00:52.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Have you tried any of this in real life? Or just SIM?
Dave
Always wear safety glasses while programming.
its all in real life. I only use the MPLAB SIM when I have a problem I can't reason out, like why does the int hang. for that i need to see registers. But it showed up in real life first by my LED not flashing.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Further explanation after my reply in the "Bug" thread.
When there was ...
LATF = LATF ^ 1
LATF is is BANK7, and since PBP thought it was in BANK0, it would have changed to BANK7 to access LATF, and at that point it knew it was in BANK7.
So then it changed back to BANK0 to access CNT, PORTA, PORTC etc.
When the LATF statement was commented, it thought it was still in BANK0, and didn't try to change the bank, not knowing what bank it was really in at the start of the interrupt.
Remember that this type of ASM interrupt using PBP statements, goes against the standard rules of interrupts.
I'm still embarrassed though.![]()
DT
Why???
So
BSR = 0
at the beginning of the ISR will do what with LATF?
I thought it had something to do with being in the wrong bank, but like you said CNT was already in BANK 0.
How should this be done? I am getting more confused than normal.Remember that this type of ASM interrupt using PBP statements, goes against the standard rules of interrupts.
Dave
Always wear safety glasses while programming.
I think PBP assumes its in BANK0 unless it does something in a different bank. Since LATF is not in BANK0, PBP will clear the BSR after executing LATF line. When I comment LATF line, sometimes the Interupt occurs during an instruction where BSR !=0, so in the interupt PBP assumes BANK0 for the BANK0 stuff.
Does this make sense? Setting BSR=0 upon entering the ISR will make sure PBP is not confused
Thank you Darrel for letting me keep some of my hair so I can pull it out on the next problem.
Last edited by cncmachineguy; - 21st December 2010 at 04:05. Reason: typo
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Well I am not too sure where the standard rules for interupts can be found, but in this instance, I am using PBP statements but ignoring all PBP context when entering and exiting the ISR. If I had actually written this in ASM, I MAY not have had this problem because I MIGHT have remembered to set BSR to what I needed. But at least I would NOT have thought it was a PBP issue.Remember that this type of ASM interrupt using PBP statements, goes against the standard rules of interrupts.
At the end of the day, it is really my lack of understanding how PBP thinks. Now that I realize PBP assumes BANK0 all the time (maybe I even read that in the manual), I see why this is broke and why it is my fault as the programmer.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
How did Protus make this work???When the LATF statement was commented, it thought it was still in BANK0, and didn't try to change the bank, not knowing what bank it was really in at the start of the interrupt.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Bookmarks