View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
What does a PIC do when it's not programmed? |
Posted: Sat Feb 07, 2004 3:00 am |
|
|
Hi guys,
I have a battery project which I want programmed late in the manufacturing process.
What does a PIC do when there is no program in it? I presume that all the registers are at power on defaults? But are they safe in this state reliably? By safe I mean stable with all I/O at inputs etc. etc. The PIC will be getting power as soon as the batteries are connected!
I can't afford for parts of the circuit to be accidentally powered up by the 'blank' PIC and hence drain the battery. I have pulled these control lines 'off' with 10k resistors but obviously the PIC can power them up if it wants to!
I am intrigued to know what a un program PIC does when you power it up!
Will |
|
![](templates/subSilver/images/spacer.gif) |
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Sat Feb 07, 2004 10:28 am |
|
|
The data sheet for each PIC gives the default states of all register bits and I/O pins. Check the sheet for your PIC. For example, the PIC16F628A starts with TRISB as 0xFF so all of PortB is input and their internal pull-ups disabled (OPTION.RBPU=0). The fun continues for all ports and registers...
From memory, I thought the unprogrammed state of the FLASH was 0x00 (SLEEP) or 0x3FF (ADDWL). Again, this is from memory so don't trust me until you confirm it by reading a factory fresh part. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Feb 12, 2004 3:36 pm |
|
|
I thought the PIC would just stand there and DROOL.
(sorry, couldn't resist) |
|
![](templates/subSilver/images/spacer.gif) |
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Thu Feb 12, 2004 4:07 pm |
|
|
As rwyoung said, an empty PIC's flash is filled 0x3FFF which is ADDLW 0xFF, so it you power up an empty PIC it will sit there in an endless loop adding 255 to W really fast ![Very Happy](images/smiles/icon_biggrin.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|