View previous topic :: View next topic |
Author |
Message |
Guest
|
I get get MCLR/B3 pin to function as an output with PIC12F51 |
Posted: Sun Mar 18, 2007 3:27 pm |
|
|
It's been a long time since I've been programming PICs and the CCS compiler is a new environment for me, so bear with me. I've been having problems getting the comparator and outputs working correctly so, for test purposes I wrote this:
Code: | #include <12f510.h>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
#use delay(clock=4000000)
void main() {
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
setup_comparator(VR_A0_OUT_ON_A2);
while (TRUE)
{
if (!C1OUT)
{output_high(PIN_B4);
output_high(PIN_B3);
}
else
{output_low(PIN_B4);
output_low(PIN_B3);
}
if (C1OUT)
output_high(PIN_B5);
else output_low(PIN_B5);
}
} |
Everything works correctly now except for the MCLR/B3 pin stays low regardless of the condition of C1OUT.
This should be easy but it's driving me nuts. Any help would be greatly appreciated.
Bullgator |
|
|
Bullgator
Joined: 18 Mar 2007 Posts: 2
|
|
Posted: Sun Mar 18, 2007 3:30 pm |
|
|
Man, my first post and I screw up the title. Obviously it should read, "I can't get..." |
|
|
Ttelmah Guest
|
|
Posted: Sun Mar 18, 2007 3:37 pm |
|
|
Read the data sheet.
Section 5.4.
What can RB3 do?... |
|
|
Bullgator
Joined: 18 Mar 2007 Posts: 2
|
|
Posted: Sun Mar 18, 2007 4:02 pm |
|
|
Wow, I feel like an idiot but at least I know the answer now. Thanks for the quick reply. |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 19, 2007 3:29 am |
|
|
There are so many 'caveats' of this sort with the PIC, especially given the number of chip variants, and peripherals attached to pins that can interfere with the operation as well, that it is a common type of problem...
At leats it was a simple problem!...
Best Wishes |
|
|
|