View previous topic :: View next topic |
Author |
Message |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
Statements necessary? |
Posted: Thu May 19, 2005 1:39 am |
|
|
look at this code please:
void main()
{
setup_psp(PSP_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while (1)
{
}
}
Those 3 setup statements put: * The PSP off
* The comparator module off
The question is: Is this necessary? IF I put nothing or that, isn't that the same? (on power-on, all peripherals are disabled by default?)
thank you |
|
|
Ttelmah Guest
|
|
Posted: Thu May 19, 2005 4:02 am |
|
|
Remember that you can arrive at the start of the program, by other routes than a POR. If (for instance), you have stack overflow reset enabled, or brownout reset enabled, you will arrive at the start of the program, with the state of the devices 'indeterminate'. Also though some devices show themselves as disabled by default, there are a suprising number of erratum relating to the startup behaviour. Putting things into a 'known' state, is safer programming, but in many cases parts at last of this can be skipped, if you are sure the system will only start from a power-on state...
Best Wishes |
|
|
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Mon May 23, 2005 2:10 am |
|
|
Dear Hamlett;
ok I understand that that is safer programming. But what can you say of the status of all I/O ports after a brownout reset or so? |
|
|
telmah Guest
|
|
Posted: Mon May 23, 2005 4:06 am |
|
|
Depends on the chip.
_Normally_, the default 'reset' state is warranted for POR, and BOR, _but not_ for a watchdog reset. This is the case for most chips, but there are a couple with erratas over this, which do not reset everything, even in the BOR state.
Best Wishes |
|
|
|