16f877a: PCLATH register


Closed Thread
Results 1 to 10 of 10
  1. #1
    herve's Avatar
    herve Guest

    Question 16f877a: PCLATH register

    Could somebody give me a simple example, showing how to use " PCLATH register", in a short program. My objective is to solve the message 306: Crossing page boundary - ensure page bits are set", which appears in my program. My program is done with MPLAB IDE V6.60.

    Thank you in advance,

    Best regards,

    Hervé.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Hi,Herve

    You can forget about Message 306 ... PBasic cares for you !!!

    It can be cancelled using :

    @ Errorlevel -306

    at the top of your program ...

    OR using PM Compiler ... !!!

    Now PCLATH permits to use a larger adressing range than an asm CALL allows, Look at fig 2.3 p 19 of the Datasheet : it explains the different BANKS of memory. PCLATH permits to choose one of these Banks.

    a look at page 32 will show you how addressing is done ...

    Good readings
    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    herve's Avatar
    herve Guest


    Did you find this post helpful? Yes | No

    Wink 16f877a: 306 message

    Hello Acetronics,
    I have already used "ERRORLEVEL - 306". It was OK to suppress the message, but when I launched the program, I faced with problems at the level where the message 306 was indicated (before the addition of "ERRORLEVEL-306"). So, I concluded that I could not ignore this message.

    I am going to analyse the datasheet, in accordance with your proposal, but could you give me a short example of program using PCLATH register, in order that it completes my analysis efficiency ?

    Thank you in advance,

    Best regards,

    Hervé.

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink THE good question ...

    Quote Originally Posted by herve
    Hello Acetronics,
    I faced with problems at the level where the message 306 was indicated , ... but could you give me a short example of program using PCLATH register, in order that it completes my analysis efficiency ?

    Hervé.
    Hi, Hervé

    Using pure PbP would never involve such problems ... sooooooo, WHAT do you do and want to do here ????????????????????

    My crystal ball is gone for holidays ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    herve, The message is just a warning. As long as you are not using the BRANCH statement you should be OK. If you are using the BRANCH statement in your program then change it to BRANCHL. This is the BranchLong statement and is used when branching to other parts of your program that are not in the same page (crossing page boundries).

    Dave Purola,
    N8NTA

  7. #7
    herve's Avatar
    herve Guest


    Did you find this post helpful? Yes | No

    Unhappy 16f877a: message 306 / PCLATH

    Hello Dave and Alain,
    I am not using any "BRANCH procedure". My program is only using a lot of "GOTO" and "CALL" instructions. People explained me that this large number of "GOTO" and "CALL" is the reason why there is the message 306 (Crossing page boundary -- ensure page bits are set): the pic program memory (where my program is saved) is divided into pages due to limitation in the program counter size that can't carry the whole address bits for the whole memory. My program may have exceeded the size of one page so it crossed the page boundries to the next page. So the pc (program counter) overflowed.

    The solution would be to adjust PCLATH register.

    That is why I would like someone to give me an example of PCLATH use, through a short program, in order that I could know how to do with this PCLATH.

    If you could help me, I thank you in advance,

    Best regards,

    Hervé.

  8. #8
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by herve
    ...My program is only using a lot of "GOTO" and "CALL" instructions. ...
    herve,

    You are missing the (same) message from the people trying to help you. Everybody gets the 306 warning message (which is not an error message, just a warning) if their program crosses a page boundary – everybody. Are you just getting the warning or is your program not doing what you expect? If it is the latter, then move your ASM routines to the first code page and makes sure this routine does not jump forward across a page boundary. If your ASM routine “intends” to jump forward across a page boundary, you can adjust bits 3 and 4 of PCLATCH just before the ASM CALL or GOTO. Personaly, I wouldn't go there unless you are well versed in ASSEMBLY programming. Again, see:

    http://www.picbasic.co.uk/forum/showthread.php?t=555

    Good Luck
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink No Magic here ...

    Hi, Hervé

    Here an example ( ASM source ... )

    REDCYL ;SUB pour lire SEUIL et NCYL
    movlw 1 ;Aller dans LTABLE chercher le SEUIL (negatif)
    ;de ligne rouge
    bcf PCLATH,0 ;LTABLE est la page 2(en h200)
    bsf PCLATH,1 ;donc PCLATH =2
    call LTABLE

    and somewhere further

    LTABLE org h'200' ;Table des delais N =367 - 1500 t/mn(0° avant,soit T/4)
    addwf PCL,f ;sauter au bon endroit h34=opcode pour RETLW

    INCLUDE c:\aepl\Oltab.txt ;ici la LTABLE préalablement générée par le prog. gentab.bas


    The goal is to retrieve a value in a Lookup table ...

    BUT you NEED to know the page number ... where you want to jump to !!!

    So, a solution is to place " manually" your called stubb to a known location ( not "squatted" ) by PbP ... :

    ORG xxxx

    CalledStubb
    .....
    .....

    PbP example

    '************************************************* ****************************
    'Table des Valeurs d'avance en 200h - longueur Maxi 254 lignes !!!
    '************************************************* ****************************

    asm

    bcf PCLATH,0
    bsf PCLATH,1

    call Table

    Movwf _Avance

    endasm

    and further, at the very top high free program location.

    asm


    ORG 200h
    Table

    movfw _Index
    addwf PCL,F

    Include C:\Documents and Settings\Alain\Mes documents\Avance.txt


    endasm

    END

    No secret there ...

    Bonnes vacances ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    herve's Avatar
    herve Guest


    Did you find this post helpful? Yes | No

    Smile 16f877a: 306 message

    Hi everybody,
    Thank you for all your elements. I am waiting for the week-end to analyse them in details (lack of time during the week !).

    Best regards,

    Hervé.

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. Can anyone help a newcomer?
    By scopit in forum Schematics
    Replies: 18
    Last Post: - 20th October 2009, 09:23
  3. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  4. MX7705 or AD7705 experience
    By FM11 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th January 2006, 21:54
  5. Problems with 16F877A code
    By NightHawk2 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th August 2003, 01:36

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts