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 CCS Technical Support

How to distinguish a reset_cpu() and a power up restart

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ivar Boer
Guest







How to distinguish a reset_cpu() and a power up restart
PostPosted: Tue Feb 18, 2003 6:39 am     Reply with quote

Hello programmers,

Iam using a PIC16F877A processor.
I have implemented the function reset_cpu(). This function is translated in assmble code goto 0x000. After this function I want to do a restart cause check with the function restart_cause(). If both bits (!TO) and (!PD) are 1 a power up occured.

When a power up occured my Time Counters have to be set to 0, otherwise not.

Now the problem is that the restart_cause() function always sees a power up (I think this status of the last power up), which means the reset_cpu() function does not infect bits (!TO) and (!PD).

Can someone help to distinguish these types of restarts from eachother in a nice way.

Thanks!
___________________________
This message was ported from CCS's old forum
Original Post ID: 11824
Tomi
Guest







Re: How to distinguish a reset_cpu() and a power up restart
PostPosted: Tue Feb 18, 2003 7:15 am     Reply with quote

I use the PowerOn bit which is cleared only if the PIC is powered on. You must set this bit by software after reset (see Chapter 2.2.2.8 for details):
#byte PCON = 0x8E

if (!bit_test(PCON,1)) {
DoPowerUp(); // what to do in case of power-up
bit_set(PCON,1);
}


Then I implement a "full-restart" as:
bit_clear(PCON,1); // force PIC to execute power-up function
while (1) ; // watchdog does the job

:=Hello programmers,
:=
:=Iam using a PIC16F877A processor.
:=I have implemented the function reset_cpu(). This function is translated in assmble code goto 0x000. After this function I want to do a restart cause check with the function restart_cause(). If both bits (!TO) and (!PD) are 1 a power up occured.
:=
:=When a power up occured my Time Counters have to be set to 0, otherwise not.
:=
:=Now the problem is that the restart_cause() function always sees a power up (I think this status of the last power up), which means the reset_cpu() function does not infect bits (!TO) and (!PD).
:=
:=Can someone help to distinguish these types of restarts from eachother in a nice way.
:=
:=Thanks!
___________________________
This message was ported from CCS's old forum
Original Post ID: 11827
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