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

Power Up Timer question

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



Joined: 09 Dec 2003
Posts: 5

View user's profile Send private message Send e-mail Visit poster's website

Power Up Timer question
PostPosted: Wed Dec 10, 2003 8:25 am     Reply with quote

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
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Dec 10, 2003 9:08 am     Reply with quote

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.
Guest








PostPosted: Fri Dec 12, 2003 7:57 am     Reply with quote

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?
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Fri Dec 12, 2003 8:24 am     Reply with quote

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.
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