Sharing experience about PIC configurarion bits

Status
Not open for further replies.

MrNobody

New Member
Hi,
I was reading about configuration bits and was trying to think about it from the perspective of real-world applications where the execution of the PIC needs to be foolproof in the sence that it as stable as it is designed for. For example, I read that if the VDD of the PIC gets below a certain level, depending on what situation/setting the PIC is used, it may run in an unstable manner. Because of that, we enable BOR right?

There are few fuses that I need inputs on whether to use it or not. So, if you are free, please share your experience related to using the fuse. Below are my thoughts on the different fuses.

Oscillator - Internal or external?:
If internal oscillator is used, then there are 3 to 4 less components on the board and that safe cost. So far, unless the PIC is used to perform tasks that requires perfect timing such as UART or any serial communication, then using Internal oscillator is fine because internal oscillator is not as accurate as external oscillator. How about power consumption? Is there any major differences? Any other thoughts?


Watchdog Timer:
Well, don't really use it. If the code is bug free and everything seems to perform well during testing, there is no reason to use WDT to reset the PIC is there?

Power Up Timer:
Use it so that the PIC will start executing the instructions when everythhing is stable. The timer gives the PIC time to stablelize.

MCLR - Enable or disable:
Well, if the product is ready for market and the code is finalise, there is no reason to enable the MCLR pin is there? Besides, enableing it means that we have less I/O pin to use. So, if everything is well, I would not enable it.

Code Protect:
I'm not sure about this. I heard that even though the code protest feature is set, the code can still be read by removing a layer of the PIC. How true is that? Can somebody please confirm?

Brown Out Reset:
I would enable it but will let SBOREN to control the BOR function.

Internal/External Switch Over Mode:
I would enable it if the PIC spends most of its time in sleep mode and only wake up to execute few instructions before it goes back to sleep so that it consumes less power.

Monitor Clock Fail-safe:
Well, what is the chances of external oscillation malfunctioning? So, is there really a need to enable this fuse? Besides, enableing it would mean that the internal oscillator is running as well as the external oscillator because the external oscillation is compared to the internal oscillation. This will comsume more power wouldn't it?
 
Watchdog Timer:
Well, don't really use it. If the code is bug free and everything seems to perform well during testing, there is no reason to use WDT to reset the PIC is there?

Bug free code? Testing procedures that test all possible states? Those would be nice but back in the real world, any non-trivial bit of code has the potential for bugs, and testing cannot always find them.

I would always leave the WDT on in finished code.
 
Internal/External Switch Over Mode:
I would enable it if the PIC spends most of its time in sleep mode and only wake up to execute few instructions before it goes back to sleep so that it consumes less power.

I don't think that you need to enable this if you want to use the sleep command. Using the sleep command doesn't change the clock speed, it just stops completely.
 
Thanks for the inputs.

Diver300:
I was reading the "Two-Speed Clock Start-up Mode" in the link below
https://www.mikroe.com/en/books/picmcubook/ch8/. Below is an excerpt from there explainaing on Sleep and Wake-up. Hope it helps to clarify what i was trying to say.

When conditions for wake-up are met, the microcontroller will not immediately start operating because it has to wait for clock signal frequency to become stable. Such delay lasts for exactly 1024 pulses. After that, the microcontroller proceeds with program execution. The problem is that very often only a few instructions are performed before the microcontroller is set up to Sleep mode again. It means that most of time as well as power obtained from batteries is wasted. This problem is solved by using internal oscillator for program execution while these 1024 pulses are counted. Afterwards, as soon as the external oscillator frequency becomes stable, it will automatically take over the “leading role”. The whole process is enabled by setting one bit of the configuration word. In order to program the microcontroller it is necessary to select the Int-Ext Switchover option in software.
 
My thoughts,

Oscillator - Internal or external?:
The internal oscillator is more than adequate for most tasks including serial communication. It's only really clock type circuits that need the accuracy of a crystal. OTOH, one reason to use an external crystal is the increase in speed available.

Watchdog Timer:
Always enable this in finished code. I know that I write bug free code and so don't worry about it. However, I have no control over nearby lightening strikes which may corrupt my variables and cause a hang.

Monitor Clock Fail-safe:
I like this feature. I recently designed a GLCD serial board and if you put a crystal on the board it runs at 20MHz, no crystal and it switches to the internal oscillator at 8MHz. The choice is left with the end user.

Mike.
 
And, whilst we're talking about configuration bits,

Did you know you can type
mcc18 --help-config -p=18f4550
in a dos window and you get the configuartion settings for whichever pic (18 only) you put in the command.

The above returns,

Mike.
 
Some programmers will not reprogram the PIC if MCLR is disabled and the PIC is using the internal oscillator. MCLR is usually, or should I say always, an input only pin (It could be an open drain I guess) because Vpp must rise above Vdd. I would only disable MCLR if there were NO other pins left to use.
Code Protect:
I'm not sure about this. I heard that even though the code protest feature is set, the code can still be read by removing a layer of the PIC. How true is that? Can somebody please confirm?
It will make it harder to steal your code. Nothing stops the determined hacker however.
Monitor Clock Fail-safe:
Well, what is the chances of external oscillation malfunctioning?
It happens. Crystals can shatter internally when dropped or just fail from age or manufacturing defects. Crystal oscillators are high impedance circuits and a little moisture can upset them. For mission critical circuits, it's always good to add as much redundancy as possible.
 
Last edited:

I was programming a stopwatch the other day using Timer2 interrupt running internal oscillator. I run it and compared it to an actual stopwatch. For the first 1 minute or so, it was running fine. After that, i begin to see the difference in time. This must be the reason for the difference in time, because i was running on internat oscillator.
 

Yes, the internal oscillator is only accurate to 1% and so is not suitable for clock/stopwatch applications (1% = 15 minutes per day). It is however adequate for most other tasks.

Mike.
 
This is a great thread.

PIC18 configuration info is also available from MPLAB HELP. Select Topics and look under language tools.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…