Searching \ for '[PIC]: part of program only once' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: 'part of program only once'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: part of program only once'
2003\03\25@183901 by ?c2FtbyBiZW5lZGnoaeg=?=

Hi all!

I'm building central heating controller. In INIT phase of my program there
is a few instructions that preload first five EEPROM locations with number
five. What I'd like to know is: how do I tell the PIC that it should execute
this part of program only at first go after programming the PIC and that it
shouldn't touch EEPROM in INIT phase after any kind of reset. Is it POR or
BOR bit that I should test?
I'm using 16f877.

Thanks in advance, Samo

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\03\25@184935 by Dwayne Reid

flavicon
face
At 07:57 PM 3/25/03 +0100, =?iso-8859-2?B?c2FtbyBiZW5lZGnoaeg=?= wrote:
>Hi all!
>
>I'm building central heating controller. In INIT phase of my program there
>is a few instructions that preload first five EEPROM locations with number
>five. What I'd like to know is: how do I tell the PIC that it should execute
>this part of program only at first go after programming the PIC and that it
>shouldn't touch EEPROM in INIT phase after any kind of reset. Is it POR or
>BOR bit that I should test?

Why not just embed your eeprom constants into the source code and let the
programmer write the eeprom?

dwayne

--
Dwayne Reid   <spam_OUTdwaynerTakeThisOuTspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\03\25@185358 by Brendan Moran

flavicon
face
>  What I'd like to know is: how do I tell the PIC that it should execute
>this part of program only at first go after programming the PIC

Why not just program the EEPROM when you program the PIC?

Or do you want these values to be loaded every time the power to the PIC is
interrupted?

--Brendan

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\03\25@185832 by Timothy Box

flavicon
face
1.Set a flag in the Eeprom on start up then load the 5's in unless the flag
has been set before

2. Don't do it in the code. Pre load the EEprom at program time.

Tim

{Original Message removed}

2003\03\25@190032 by Des Bromilow

flavicon
face
I'm not sure if I understand the reasons, but why not have a sixth EEPROM bit which is a "write protect" for the other five?
Simply write your program flow such that it checks the "writeprotect bit" and then only writes tot he other EEPROM cells if you want it to..

HTH,
Des

>>> .....samo.benedicicKILLspamspam@spam@VOLJA.NET 26/03/03 4:57:14 am >>>
Hi all!

I'm building central heating controller. In INIT phase of my program there
is a few instructions that preload first five EEPROM locations with number
five. What I'd like to know is: how do I tell the PIC that it should execute
this part of program only at first go after programming the PIC and that it
shouldn't touch EEPROM in INIT phase after any kind of reset. Is it POR or
BOR bit that I should test?
I'm using 16f877.

Thanks in advance, Samo

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\03\25@190242 by Josh Koffman

flavicon
face
Programming the data EEPROM as others have suggested seems like the
easiest answer. Alternatively you could just read the EEPROM to see if
those locations hold what you expect them to. If they don't, load them.
Another (much more complex) way would be to make your code load the
values the first time it's run, then modify the program memory to skip
those instructions forever after.

Seems like a lot of work though.

Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
       -Douglas Adams

samo benedihih wrote:
> I'm building central heating controller. In INIT phase of my program there
> is a few instructions that preload first five EEPROM locations with number
> five. What I'd like to know is: how do I tell the PIC that it should execute
> this part of program only at first go after programming the PIC and that it
> shouldn't touch EEPROM in INIT phase after any kind of reset.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\03\26@013803 by erholm (QAC)

flavicon
face
If the program *knows* what values to expect i the EEPROM,
why then store them in the EEPROM at all ?

Jan-Erik Soderholm.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@034306 by Alan B. Pearce

face picon face
>What I'd like to know is: how do I tell the PIC that it
>should execute this part of program only at first go
>after programming the PIC

Load the eeprom locations as part of the chip programming by specifying
default values in your source code. You then do not need the code to load
these values, unless you have code to reset the default state.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@043358 by Eric Bohlman

picon face
3/25/03 12:57:14 PM, samo benedihih <EraseMEsamo.benedicicspam_OUTspamTakeThisOuTVOLJA.NET> wrote:

>I'm building central heating controller. In INIT phase of my program there
>is a few instructions that preload first five EEPROM locations with number
>five. What I'd like to know is: how do I tell the PIC that it should execute
>this part of program only at first go after programming the PIC and that it
>shouldn't touch EEPROM in INIT phase after any kind of reset. Is it POR or
>BOR bit that I should test?

Neither.  You somehow need to use one of the EEPROM locations to store a "known good" value which
you check for.  If you can't find it, you assume that the EEPROM is uninitialized or corrupted and
initialize it.  One way to do this is with a checksum or something similar like a CRC.  Another way,
which I used in my most recent design, was to range-check each EEPROM location; all the ones I was
using were settable from an LCD menu, so I had to keep range limits in my code in any case.  That
wouldn't work, though, for locations where all 256 possible values were allowed; in that case, I'd
go with a checksum.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@052124 by daniel_sweet

picon face
If I understand correctly, you want to program 5's into the data EEPROM when you first program the device, and thereafter let them be whatever the PIC has set them to. In MPLAB the assembler directive "de" can be used to do this.

org H'F00000' ; Assembler Directive to Initialise EEPROM at programming - h'F00000' is data EEPROM                                 ;address for 18f252, may change depending on your device

de 05h,05h,05h,05h,05h    ; declare EEPROM - sets 1st,2nd,3rd,4th and 5th EEPROM location to 05h

This will set them during programming and will then not be set again.

See below:

http://techweb.ceat.okstate.edu/eet/EET%203264/Notes/3264%20Ch%2018.doc

Regards,
DAN
{Original Message removed}

2003\03\26@072354 by Olin Lathrop

face picon face
> I'm building central heating controller. In INIT phase of my program
> there is a few instructions that preload first five EEPROM locations
> with number five. What I'd like to know is: how do I tell the PIC that
> it should execute this part of program only at first go after
> programming the PIC and that it shouldn't touch EEPROM in INIT phase
> after any kind of reset. Is it POR or BOR bit that I should test?

Whoa, step back and look at the overall problem.  This EEPROM writing
smells like the answer to the wrong question.  Do you want the EEPROM
initialized only the first time its run or on every powerup?  If the
former, just put the data into the source code.  If it needs to be
initialized every powerup but not on other resets, then RAM seems more
apporpriate.  Explain the overall problem you are trying to solve.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

2003\03\27@091045 by Micro Eng

picon face
What I have done is this.  When the EEPROM is virgin, meaning its totally
erased, the values should be 0xFF (but on a new part I've actually seen
0x00) so test some location for either value, then init the EEPROM and write
over that same 'test' location with something else.

Next time you go into the program, first thing is test for the 'new' value.
If its present, ignore the writing else init the locations.






{Quote hidden}

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu>

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...