![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
12f629 reset problem |
Posted: Thu Oct 04, 2007 10:53 pm |
|
|
Dear sir,
here i am using 12f629, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534
In my circuit i have connected switch to pin no. 4 and LED at pin no. 5
And using internal MCLR. I have to make LED ON whenever switch is ON
i.e. closed & i/p at pin no. 4 is logic zero.
And OFF when switch is OFF i.e. open & i/p at pin no. 4 is logic one.
for this purpose i used the statements like this,
if(INPUT(PIN_A3)== 0)
LED ON; //switch closed i.e s/w ON
else
LED OFF; // switch open i.e. s/w OFF
BUT for this i am not using any pull up for switch & making this pin as out put pin.
Bcz i want check only logic level of pin no.4
This is working OK,
But sometimes the microcontroller not reseting.forcefully I have to connect pin no.4
to GND.
it is necessary to make pin no.4 as input to check logic level to avod reseting problem _________________ Thank You,
With Best Regards,
Deepak. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 05, 2007 12:17 am |
|
|
Post the test program. |
|
![](templates/subSilver/images/spacer.gif) |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
12f629 reset problem |
Posted: Fri Oct 05, 2007 2:30 am |
|
|
Here is my test programe,
Code: | #if defined(__PCM__)
#include<12F629.h>
#fuses INTRC_IO,NOWDT,PUT,NOMCLR,PROTECT,NOCPD,BROWNOUT
//Internal RC Osc, no CLKOUT,No Watch Dog Timer,Power Up Time ON,Internal MCLR,Code Protect ON,No EE protection,Brownout detect ON,
#use delay(clock = 4000000) // INTERNAL 4 MHz FREQ.
void main()
{
PORT_A_PULLUPS(FALSE);
SET_TRIS_A(0x00);
SETUP_COMPARATOR(NC_NC_NC_NC); // Make comparator off
while(TRUE)
{
if(INPUT(PIN_A3) == 0)
OUTPUT_HIGH(PIN_A2);
else
OUTPUT_LOW(PIN_A2);
}
}
|
_________________ Thank You,
With Best Regards,
Deepak. |
|
![](templates/subSilver/images/spacer.gif) |
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
|
Posted: Fri Oct 05, 2007 5:47 am |
|
|
OK there are a number of things wrong here.
Quote: | In my circuit i have connected switch to pin no. 4 and LED at pin no. 5 And using internal MCLR. |
and
Quote: | But sometimes the microcontroller not reseting.forcefully I have to connect pin no.4 to GND. |
If you use the internal MCLR, the only way to reset the device is to turn the power off and on again.
Also
Quote: | & making this pin as out put pin. |
You cant - MCLR pin is an input only.
Quote: | BUT for this i am not using any pull up for switch |
You need a pull up resistor, otherwise the pin is floating.
I see that you have dabbled with
Quote: | PORT_A_PULLUPS(FALSE); |
If you are hoping to use the internal pull up resistor for the switch - you can't because there isn't one.
Although not stated, you do have resistors on the LED I hope?
You will also have to look at debouncing of you switch. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|