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

Reset PIC16 using an IO pin connected to MCLR

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



Joined: 14 Jun 2011
Posts: 24
Location: St. Louis

View user's profile Send private message Send e-mail

Reset PIC16 using an IO pin connected to MCLR
PostPosted: Thu Sep 08, 2011 7:27 pm     Reply with quote

I need to do a reset to the PIC (16F690)after performing a function. I need to do the equivalent of a power reset but without requiring manual interface. I want to connect one of the IO pins to the MCLR pin - drive it low so that a reset occurs. I am having trouble with the connection/wiring.

Right now I have a 1k resistor between Vdd and MCLR pin; capacitor between MCLR and ground. My thought is to then connect a 1k resistor from an IO pin to the MCRL pin - so when the IO pin goes low it would force a reset on MCLR - this is not working.

Any suggestions or better ideas?
Thank you - I appreciate your advice.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Sep 09, 2011 1:31 am     Reply with quote

Why are you trying to do a hardware reset?

The problem with this is that you must meet the reset timing spec for the PIC. That's impossible with simple hardware as as soon as you drive the IO pin, you loose control because the PIC isn't running: it's resetting! Therefore you must use hardware that will generate the right length reset pulse - a "proper" reset generator (there are plenty out there with extras like watchdog, power monitoring and the like: try Maxim/Dallas, Microchip, Ti and AD). If you are a dyed-in-the-wool hobbyist you can go back to the 70s and brew one up with a 555 if you want... but there are better, more modern ways.

The conventional and much simpler way of doing this is to do a software reset. In CCS simply call reset_cpu(). This though is a warm start and doesn't set all the SFRs to their reset state, but all programs should take care of that by proper initialisation at the start of main().

The PIC and CCS will tell you why it (re)started: reset_cause() will tell you. That can be quite useful.

RF Developer
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 09, 2011 5:00 am     Reply with quote

RF_D is right on this one ! These new fangled PICs have everything built inside of them and CCS has nice software to do what you want...but.. if you're dead set on doing a hardware resetwith the PIC you could have the PIC toggle a 74123 ret. one shot that feeds the *MCLR pin. Setup right,if you don't hit the 74123, it'll send a pulse to the *MCLR pin and you'll have reset.The 'new' 555 can do the same thing but I made a LOT of watchdog timers using the 74123 in the 70s before the 555 came out.
Yessh that's 40 years ago....do they still make 555s ?
schmez



Joined: 14 Jun 2011
Posts: 24
Location: St. Louis

View user's profile Send private message Send e-mail

Reset maybe not answer
PostPosted: Fri Sep 09, 2011 6:03 pm     Reply with quote

Thank you for the replies. I was doing a soft reset in the code but the PIC seemed to lock up. What I am doing is writing a string to memory and after executing the function the processor seems to lock up - if I hard reset everything is good. Guess, I should continue debugging to see why the PIC is locking up after I execute a write to memory function.
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Sep 10, 2011 5:05 am     Reply with quote

hmmm...sounds like your string storing function maybe trashing memory used for another variable? Remember you need to make room for n+1 locations( 'PIC'+null is 4 not 3 ).Yup, I'm guilty of forgetting that.....
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