How to set and change Configuration Bits programmatically?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72

    Default How to set and change Configuration Bits programmatically?

    Dear Sirs,
    somebody knows how (and if) it's possible to change the values of the Configurations Bits from within the application writed in PBP (or PBP + ASM)?
    The chip involved in this scenario is PIC18F4685.
    The reason why I'm asking, is because I need to upload a new firmware version using the bootloader I wrote a while ago and then this new firmware (other than run the device) should take care to switch on (or off) some of the fuses.
    I know it could be done using TBLWRT ASM instructions, but unfortunately I'm not an ASM expert...

    Any idea or suggestions/hint?

    Thank you.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,390


    Did you find this post helpful? Yes | No

    Default Re: How to set and change Configuration Bits programmatically?

    there is a search engine on the forum or
    http://lmgtfy.com/?q=runtime+config+...picbasic.co.uk

  3. #3
    Join Date
    Aug 2011
    Posts
    414


    Did you find this post helpful? Yes | No

    Default Re: How to set and change Configuration Bits programmatically?

    You may not be able to do what you want if any of the code protection bits are set...
    Code:
    Note: Code protection bits may only be written to a ‘0’ from a ‘1’ state. 
    It is not possible to write a ‘1’ to a bit in the ‘0’ state. 
    Code protection bits are only set to ‘1’ by a full Chip Erase or Block Erase function. 
    The full Chip Erase and Block Erase functions can only be initiated via ICSP or an
    external programmer.
    Since you can brick the device if you get the config bits incorrect (ie wrong osc type) I like to have the bootloader just ignore reprogramming the config bytes.

  4. #4
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72


    Did you find this post helpful? Yes | No

    Thumbs up Re: How to set and change Configuration Bits programmatically?

    Quote Originally Posted by richard View Post
    there is a search engine on the forum or
    http://lmgtfy.com/?q=runtime+config+...picbasic.co.uk
    Thank you Mr. Richard,
    of course I've did a research on the forum before posting.
    What I've missed, since I'm not an english speacking one, was to use some other words as keywods.
    Actually "Run-Time Config" is exactly what I was looking for... but simply impossible to find insisting (as I did, shame on me) using "configuration bits" and "programmatically". Most of the results lands to how to setup the configuration bits in the code, before compile it, and not "setup configuration bits on the fly".

    BTW, your suggestions was effective and I found the right post:
    http://www.picbasic.co.uk/forum/showthread.php?t=4093

    With all the "keyword" I've included in this message, I'm pretty sure that if somebody else is looking for the same subject, will be easier to find it.

  5. #5
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72


    Did you find this post helpful? Yes | No

    Default Re: How to set and change Configuration Bits programmatically?

    Quote Originally Posted by tumbleweed View Post
    You may not be able to do what you want if any of the code protection bits are set...
    Code:
    Note: Code protection bits may only be written to a ‘0’ from a ‘1’ state. 
    It is not possible to write a ‘1’ to a bit in the ‘0’ state. 
    Code protection bits are only set to ‘1’ by a full Chip Erase or Block Erase function. 
    The full Chip Erase and Block Erase functions can only be initiated via ICSP or an
    external programmer.
    Since you can brick the device if you get the config bits incorrect (ie wrong osc type) I like to have the bootloader just ignore reprogramming the config bytes.
    Thank you for your answer.
    What you say is True.
    In the current scenario, all the CODE PROTECTION bits are set. I don't want to deal with that.
    What I'm trying to do, is to change the bits WRTC (Configuration Register Write Protection bit) and WRTB (Boot Block Write Protection bit) that are currently set, and I wish to revert to "not protected".

    Do you think it is possible?

    Unfortunately yesterday my old ICD2 decided to not work anymore. So, I've to wait for a new (and expensive ICD3), but it will be here in 5 or 6 days. So I've mandatory to wait for my own tests...

    Regards.

  6. #6
    Join Date
    Aug 2011
    Posts
    414


    Did you find this post helpful? Yes | No

    Default Re: How to set and change Configuration Bits programmatically?

    I'm not sure, but I think it treats all of the CPn, WRTn, and EBTRn as "code protection bits" so if they're set to 0 I don't think you'll be able to change them.

    According to the datasheet the WRTC Configuration protect bit can only be written via ICSP or an external programmer.

Similar Threads

  1. Set configuration bits
    By Petenausen in forum Code Examples
    Replies: 5
    Last Post: - 27th May 2013, 17:04
  2. _config set change for pic12f683
    By nbrucew in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th March 2010, 01:03
  3. configuration bits
    By Izone1173 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 18th June 2009, 04:17
  4. Set Configuration from code?
    By kevj in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th September 2008, 04:52
  5. Configuration bits
    By DJEE in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th June 2007, 19:20

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