View previous topic :: View next topic |
Author |
Message |
hello188
Joined: 02 Jun 2010 Posts: 74
|
Initialization of SFR |
Posted: Mon Jun 28, 2010 10:00 pm |
|
|
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
|
|
Posted: Mon Jun 28, 2010 10:20 pm |
|
|
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
|
Thanks |
Posted: Tue Jun 29, 2010 1:49 am |
|
|
By "used", you mean read? |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Tue Jun 29, 2010 6:42 am |
|
|
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. |
|
|
|