I have been learning(trying to at least) how to work with pic microcontrollers, and I have noticed this behavior that I am not sure whether it is just my fault or is supposed to happen. I wrote the below program with hopes to make an led blink. It does blink just fine, when connected to the pin labeled RA2, but when I connect the led to pin 15 (labeled RA6/OSC2/CLKO on datasheet) the led stays on, as though I had connected it to Vdd. Then when I put it back in RA2 where it belongs, it is off. The only way to get it back on again is connecting a 10k resistor between Vdd and MCLR (like how it is when programming). What is happening here? MCLR is also needed when tapping it to some other pins. Am I causing damage?
The circuit is 3 AA batteries powering the pic, with a 330 resistor and 3mm led in series running from pin 1 (RA2) to pin 5 (ground).
pic16f88 datasheet
Code:
#include <xc.h>
__CONFIG(MCLRE_ON & CP_OFF & WDTE_OFF);
void main(){
TRISA = 0x0000;
// RB6 = 0b000010;
for(;;){
RA2 = 1;
Wait();
RA2 = 0;
Wait();
}
}
int Wait(void) // gives me a nice delay of 1/3rd a second or so
{
for (int i = 0; i < 50; i++)
{
}
}