Do I need to save PCLATH?

Status
Not open for further replies.

Suraj143

Active Member
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.
 
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.
 
Hi bananasiong

I just select "program memory" & it comes a window.
In there it has line, address,opcode what to see?
 
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:
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.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…