+ Reply to Thread
Results 1 to 8 of 8

Thread: Do I need to save PCLATH?

  1. #1
    Suraj143 Newbie
    Join Date
    Jan 2007
    Location
    South Mald Isld
    Posts
    921

    Arrow Do I need to save PCLATH?

    When saving ISR context do I need to save (backup) PCLATH also?

    My code length is 600 lines.

    I’m using PIC16F876.


  2. #2
    bananasiong Excellent bananasiong Excellent bananasiong Excellent bananasiong Excellent bananasiong Excellent
    Join Date
    Mar 2006
    Location
    Malaysia
    Posts
    1,881

    Default

    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

  3. #3
    Suraj143 Newbie
    Join Date
    Jan 2007
    Location
    South Mald Isld
    Posts
    921

    Default

    Hi Thanks.

    How do I know how many pages do I have?

  4. #4
    bananasiong Excellent bananasiong Excellent bananasiong Excellent bananasiong Excellent bananasiong Excellent
    Join Date
    Mar 2006
    Location
    Malaysia
    Posts
    1,881

    Default

    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

  5. #5
    Suraj143 Newbie
    Join Date
    Jan 2007
    Location
    South Mald Isld
    Posts
    921

    Default

    Hi bananasiong

    I just select "program memory" & it comes a window.
    In there it has line, address,opcode what to see?

  6. #6
    Suraj143 Newbie
    Join Date
    Jan 2007
    Location
    South Mald Isld
    Posts
    921

    Default

    In the last line (line 600) adress is 0258.

    This is how many pages? Do I need to save PCLATH?

  7. #7
    bananasiong Excellent bananasiong Excellent bananasiong Excellent bananasiong Excellent bananasiong Excellent
    Join Date
    Mar 2006
    Location
    Malaysia
    Posts
    1,881

    Default

    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

  8. #8
    Suraj143 Newbie
    Join Date
    Jan 2007
    Location
    South Mald Isld
    Posts
    921

    Default

    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.

+ Reply to Thread

Similar Threads

  1. Pclath
    By GreenP in forum Micro Controllers
    Replies: 7
    Latest: 20th January 2008, 02:15 PM
  2. What Value to move to PCLATH
    By Suraj143 in forum Micro Controllers
    Replies: 19
    Latest: 18th September 2007, 04:31 AM
  3. BANKSEL AND PCLATH DOUBTS?
    By neelam29 in forum Micro Controllers
    Replies: 2
    Latest: 18th February 2006, 12:57 PM
  4. PCLATH
    By heida11 in forum Micro Controllers
    Replies: 2
    Latest: 19th December 2004, 12:15 PM
  5. pclath 16f877
    By jijita in forum Micro Controllers
    Replies: 1
    Latest: 13th September 2004, 05:59 PM

Tags for this Thread