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

Initialization of SFR

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



Joined: 02 Jun 2010
Posts: 74

View user's profile Send private message

Initialization of SFR
PostPosted: Mon Jun 28, 2010 10:00 pm     Reply with quote

Hi
I know that the most of the special function registers in PIC flash devices have default values on power up.

For example datasheet for any flash device states that the TRISX registers are set to 0xFF on power-up.

However, I am reading Application Note 607, and on the page 7, it states that all RAM has to be initialized by the program, including SFR.

I don't know if I have to do that with the datasheet for the device clearly
stating the device value.

Thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 10:20 pm     Reply with quote

The important statement is the one shown in bold:
Quote:

Note: RAM locations should be initialized
before they are used. Use of an uninitialized
location will cause proper device operation
with the improper values. That is, it will do
what you told it to do, not what you wanted
it to do.

You don't have to initialize unused general purpose
RAM locations.
hello188



Joined: 02 Jun 2010
Posts: 74

View user's profile Send private message

Thanks
PostPosted: Tue Jun 29, 2010 1:49 am     Reply with quote

By "used", you mean read?
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Tue Jun 29, 2010 6:42 am     Reply with quote

Yes, but my guess would be the most likely cause of a failure would be an increment operation. So if you had something like

Code:

  if (times_through_loop++ >= 100)
    do_something_important();


and you wanted to increment the counter 100 times before executing some routine, it would be important to have the loop counter start at 0. A normal memory read would most likely occur after that location had been written at least once.
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