When saving ISR context do I need to save (backup) PCLATH also?
My code length is 600 lines.
I’m using PIC16F876.
When saving ISR context do I need to save (backup) PCLATH also?
My code length is 600 lines.
I’m using PIC16F876.
Hi there,
Yes you do if there's different pages in the main routine and the interrupt routine. My practice is to save it.
bananasiong
Hi Thanks.
How do I know how many pages do I have?
Look at the program memory used. Bit 3 and 4 in PCLATH (or bit 11 and 12 in PC) indicates the page used.
Each page is 2k memory, which takes 11 bits of program memory. So if your program doesn't use up to bit 11 and 12 (both are 0), then you don't have to save them.
bananasiong
Hi bananasiong
I just select "program memory" & it comes a window.
In there it has line, address,opcode what to see?
In the last line (line 600) adress is 0258.
This is how many pages? Do I need to save PCLATH?
0x0258 = 0b0001001011000
The program is within the page 0. So, what do you think?
*EDIT:
One page is 2k, which is 2048 (0 to 2047, or 0x0000 to 0x07ff)
In binary,
Page 0: 0b0000000000000 to 0b0011111111111
Page 1: 0b0100000000000 to 0b0111111111111
Page 2: 0b1000000000000 to 0b1011111111111
Bit 11 and 12 indicate the page, as in bit 3 and 4 in PCLATH.
Last edited by bananasiong; 27th February 2009 at 06:24 AM. Reason: Additional info.
bananasiong
Ok bananasiong now I understood.
Thanks for your help.
So my code is within the page 0.So I don't need to save the PCLATH.