View previous topic :: View next topic |
Author |
Message |
Jon Fick
Joined: 09 Dec 2003 Posts: 5
|
Power Up Timer question |
Posted: Wed Dec 10, 2003 8:25 am |
|
|
I encountered something pertaining to the power-up-timer that I've not seen before...maybe it's only a brain cramp.
I'm using the 16F628 with the PUT enabled. It appears that the code actually starts running before the PUT completes it's time out. Here's the snippet of code:
#include <16F628.h>
#fuses HS, PUT, BROWNOUT, NOMCLR, NOLVP, NOPROTECT
#use standard_io ( b )
#use delay ( clock = 8000000 )
void main ( void )
{
char cX;
cX = input_b();
// etc.
}
If the code is compiled as written, the input_b function does not return the correct state of port_b. There are only two ways around this if the PUT is desired. One is to enable MCLR in the fuses statement but it means you can't use RA5 as a port bit. The other is to insert a delay statement at the beginning of the same code, as follows:
include <16F628.h>
#fuses HS, PUT, BROWNOUT, NOMCLR, NOLVP, NOPROTECT
#use standard_io ( b )
#use delay ( clock = 8000000 )
void main ( void )
{
char cX;
delay_ms ( 100 );
cX = input_b();
// etc.
}
Whether you use PUT or don't use PUT in the fuses statement, CCS compiles this code exactly the same way, character for character. Only the config word changes. (It's not a PIC sleep condition...my ensuing code never runs off the end of the MAIN function.)
Do I have to account for the 75mS (nominal) PUT time in my code??? Or, is this just the brain cramp mentioned above. I'm willing to exhaustively characterize this if anyone feels that's necessary.
Thanks for any suggestions.
Jon |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Wed Dec 10, 2003 9:08 am |
|
|
The power up timer is a fuse and does not effect the way code will be compiled. It effects how the chip comes out of a power off reset. This is well documented in the data sheet for the chip you are using. The power up timer places a delay at powerup before any code is run. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Fri Dec 12, 2003 7:57 am |
|
|
Neutone, thanks. So code is not run before the PUT times out. That's what I expected. But why does the CCS "input_b" function (and generated assembler RISC code) not return the correct state of Port B unless I first wait many tens of mS after reset? |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Fri Dec 12, 2003 8:24 am |
|
|
Anonymous wrote: | Neutone, thanks. So code is not run before the PUT times out. That's what I expected. But why does the CCS "input_b" function (and generated assembler RISC code) not return the correct state of Port B unless I first wait many tens of mS after reset? |
I can only guess but the port input circuit might just take time to raise the pin to a high state. You might experiment by shorting the MCLR pin to ground while the circuit is powered up. I would expect it to perform diferently from when you remove and apply circuit power. I doubt that the compiler is at fault in this instance. |
|
![](templates/subSilver/images/spacer.gif) |
|