PCLATH initialising for Bootloader


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Unhappy PCLATH initialising for Bootloader

    Hi there,

    It's been a while since I played here and I'm a bit rusty...

    A while ago I was loading tiny bootloader into the 16F88 and it was working but now, I cant figure what the heck I'm doing wrong, my program wont install using the bootloader, I get a error come up:

    WARNING: PCLATH not initialised before GOTO! ... could not repair.,
    Maybe you sould use some directive in your compiler to enable the use of bootloaders


    The tiny website recommends that the program must meet this requirement:

    it must have in the first 4 words of memory a GOTO to the start of the main program. (this is what the majority of the bootloaders require). So in assembler it should look something like this:



    asm

    org 0
    ;clrf STATUS
    clrf PCLATH
    goto Main
    endasm


    This codedoesnt make a lot of sense to me but perhaps there is somebody out there that can point me in the right direction.

    BTW What the heck does LATH in PCLATH stand for???

    Oh yeah, I use MCS and PICBASIC pro for compilying.. dur!
    Cheers
    J

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Out of curiosity, Did you insert DEFINE LOADER_USED 1 at the top of your code?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    A Ha!,

    I think that did the trick... btw, any idea about that LATH comment I made?

    Thanks Steve.
    J

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    PCLATH = (program counter latch high) = the latch register you write to that
    holds the value to be loaded into PCH.

    PCH is the high 5-bits of the 13-bit program counter for the 14-bit core. PCL
    is the lower 8-bits.

    You can't write directly to PCH, so you write to PCLATH. The value you place
    in PCLATH gets latched into the program counter high (PCH) when PCL is
    written.

    All 13-bits of the program counter have to be written simultaneously. That's
    the purpose of the PCLATH latch register.

    The error you're getting is because you haven't reserved enough space in the
    beginning or program memory for the Tiny loader to automatically insert the
    CLRF PCLATH instruction.

    On return from the loader sub routine PCH needs to be cleared to point to the
    program memory in bank 0 where your code is located.

    If CLRF PCLATH can't be inserted before GOTO Main, then it would jump back
    to program memory in bank 1 instead of bank 0 causing major problems.

    As Steve mentioned, inserting DEFINE LOADER_USED 1 takes care of this since
    it tells PBP to reserve the first 4 locations for loader use.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Talking

    Thats a great reply, thanks Bruce!

    J

  6. #6
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    I'm having a similar problem using the tinybootloader, but when I use microcode studio's bootloader I don't have any issues.

    When using the tiny loader the first time I bootload my program to the chip it works, but I get the following error in the Tinybootloader window:
    ----------------------
    HEX: 9 hours old, INHX32,16Fcode+cfg+eeprom , total=14546 bytes.
    Searching for PIC ...
    Found:16F 876A/877A
    WARNING: PCLATH not initialised before GOTO! ... sucessfully repaired.,
    WRITE OK. time:9.203 sec
    ----------------------

    The problem I am having is I can't bootload a new hex file to the chip after this, everytime I try I get the following error:

    ----------------------
    Searching for PIC ...
    pic sending unknown data: "K" <> E0h=à
    Check baudrate & Start Write while PIC is not sending serial data (e.g. in reset)
    ERROR!
    ---------------------

    I would appreciate any advice you may have.

    Thanks

  7. #7
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    I figured out my problem....it always helps to read directions

    My problem is that I am using a chip that is constantly sending serial commands so I needed to hold down the chip reset button and release it immeadiatly after I hit "write flash"

    This seemed to solve my issue.

  8. #8
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    Yeah that would do it.

    Btw, I still get the PCLATH not initialised before GOTO! ... sucessfully repaired.,
    message come up. Not sure what thats about but HEY, it works!

    Squib

  9. #9
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Yeah I still get that error as well, but it does work

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f877a: PCLATH register
    By herve in forum mel PIC BASIC
    Replies: 9
    Last Post: - 6th September 2006, 06:03
  3. Replies: 1
    Last Post: - 6th September 2005, 16:32

Members who have read this thread : 0

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