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

reset_cpu() question

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



Joined: 24 Jun 2008
Posts: 10

View user's profile Send private message

reset_cpu() question
PostPosted: Wed Jan 07, 2009 12:37 pm     Reply with quote

Hey,

I was wondering if there is a way to have the PIC reset itself once about 5 seconds after the program starts. I believe the above function is what I need to use, but I keep getting infinite loops. Just in case the above isn't clear, I would like the PIC to follow this order:

1. Start when powered
2. Delay 5 seconds
3. Restart
4. Continue to Program Loop

I am using the PIC18F6722 Prototyping board with PCH version 4.068.

Thanks.
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 2:50 pm     Reply with quote

Do you want to reset the PIC or reset your routine. I don't understand your application. It looks like you want to start, wait 5 seconds, then restart, which would repeat the 5 second delay infinitely. Is that what you want?

Or are you wanting on powerup to wait 5 seconds, then go into your main application? Need more info.
_________________
A HW Engineer 'trying' to do SW !!! Run!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 2:55 pm     Reply with quote

Post a small test program that shows what you want to do.
Here is an example of a test program for the reset_cpu() function:
http://www.ccsinfo.com/forum/viewtopic.php?t=29718&start=8

The program that you post should be very short, just like that,
and it should compile without errors.
Setna



Joined: 24 Jun 2008
Posts: 10

View user's profile Send private message

Clarification
PostPosted: Wed Jan 07, 2009 3:20 pm     Reply with quote

Here is a sample code that will run in an infinite loop. I would like the the reset to only occur once.

Code:

int main()
{

   int FirstPowerUp = 0;
   
   delay_ms(5000);
   if(FirstPowerUp==0)
   {
      //Would like the PIC to start up like normal, delay 5 seconds.
      //When it starts for the second time, delay five seconds,
      //and then go to the else statement where it will run a while loop.
      FirstPowerUp = 1;
      reset_cpu();
   }
   else()
   {
      while(TRUE)
      {
         //Run Program
      }
   }

}


I would like to reset the PIC because it is going to be remotely started along with a radio transmitter. The radio transmitter is modified so that the PIC can control each of the transmitters channels. The problem is that the transmitter loads with the wrong presets when started at the same time as the PIC. If i use the manual reset button after the transmitter completely powers up, it works. So I'm trying to automate this problem using the reset command.

Sorry if the explanation is not the best. Thanks.
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 3:25 pm     Reply with quote

Code:
else()


I think you want to remove the ().

You would be better off doing a DO loop instead.
_________________
A HW Engineer 'trying' to do SW !!! Run!!!
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 4:32 pm     Reply with quote

Take a look at the restart_cause() function. With it you should be able to determine the cause of the reset. If the reset was a POR then restart after 5 seconds if not then don't reset the cpu
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 4:51 pm     Reply with quote

Does the transmitter have its own initialization period that takes several
seconds ? I notice you already have 5 second delay at the start of the
PIC program. Maybe you just need to increase it to 10 seconds.

What you're proposing to do with the emulation of a hard reset, is
really just "papering over" the problem, whatever it is. You need to
find out what the real problem is, and fix it. It may well be that
it's as I proposed, that the transmitter isn't ready to take commands
until several seconds after power up (longer than 5 seconds).

Or, it may be that your PIC isn't starting up correctly from a power-on
start. Possibly that could be fixed by adding the BROWNOUT and PUT
fuses if you don't already have them.
Setna



Joined: 24 Jun 2008
Posts: 10

View user's profile Send private message

PostPosted: Wed Jan 07, 2009 5:07 pm     Reply with quote

I'm going to try using the restart_cause() function. Thanks Charlie U.

PCM Programmer,

If I'm understanding you correctly, you want me to have the PIC trigger the start of the transmitter. I have tried this using a switch. The PIC opens a gate that provides the transmitter with power and it starts. For some reason, the transmitter sometimes starts with the correct presets, but not always. However, if there both on, and I use the reset button it works.

I'm not sure if this will help, but the PIC is controlling 4 digital potentiometers. The regular potentiometers on the radio transmitter were cut off and replaced with these digital ones. The power for the potentiometers comes from the 5V power supply on the prototyping board.

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