| Author |
Message |
faraz101
Joined: 07 Mar 2007 Posts: 97 Helped: 2
|
25 May 2008 3:58 pic16f676 mclr input problem |
|
|
|
|
guys i am using mclr pin of pic 16f676 as input.but it is not working here is my code please help me.
#include "D:\PIC16F676 UPS\CODE\mclr2\mclr.h"
#define SWITCHON PIN_A3
#define MAIN_LED PIN_C0
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
while(1)
{
if(input(SWITCHON))
{
output_low(MAIN_LED);
delay_ms(1000);
output_low(MAIN_LED);
delay_ms(1000);
}
else
{
output_low(MAIN_LED);
delay_ms(500);
output_low(MAIN_LED);
delay_ms(500);
}
}
}
|
|
| Back to top |
|
 |
photonix
Joined: 15 Mar 2005 Posts: 46 Helped: 4
|
25 May 2008 4:06 Re: pic16f676 mclr input problem |
|
|
|
|
| Have you correctly set the config bit yet??
|
|
| Back to top |
|
 |
faraz101
Joined: 07 Mar 2007 Posts: 97 Helped: 2
|
25 May 2008 4:36 pic16f676 mclr input problem |
|
|
|
|
yes when i upload the hex file in melabs programming software it shows that mclr is input.
i am using ccs compiler and in project wizard i have set mclr as i/o pin.
thanx
|
|
| Back to top |
|
 |
Google AdSense

|
25 May 2008 4:36 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
laktronics
Joined: 06 Jan 2007 Posts: 945 Helped: 156
|
25 May 2008 6:10 Re: pic16f676 mclr input problem |
|
|
|
|
Hi,
Why you are writing twice Output_Low, one of them should have been Output_high ? No need to set TRIS?
Regards,
Laktronics
|
|
| Back to top |
|
 |
gebepic
Joined: 23 May 2008 Posts: 49 Helped: 6 Location: The Universe
|
25 May 2008 12:32 pic16f676 mclr input problem |
|
|
|
|
Config word
3 1 c 4 normal Means pin RA3 can be used as input
3 1 e 4 used as reset can be used ONLY as RESET
I tried to figure out your C and I undertood (maybe WRONGLY) that you use RA3 as an IO pin,in this case Config word should be 3 1 C 4 or 11 0001 1100 0100 B
gebepic.
|
|
| Back to top |
|
 |