CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Statements necessary?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

Statements necessary?
PostPosted: Thu May 19, 2005 1:39 am     Reply with quote

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







PostPosted: Thu May 19, 2005 4:02 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon May 23, 2005 2:10 am     Reply with quote

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







PostPosted: Mon May 23, 2005 4:06 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group