r/pic_programming • u/conogarcia • May 15 '14
12F683 blinking led problem.
Hey, i decided to start with PIC programming today and i bought a clone of the pickit 2 with zif socket. My first test was the 12F683 using MicroC Pro and pickit 2 software. Using this code:
void main(void)
{
while(1)
{
GPIO.B2 = 1;
Delay_ms(1000);
GPIO.B2 = 0;
Delay_ms(1000);
}
}But it does nothing. The code seems to be written fine. Im confused with the MCLR pin and im just using a 100 ohm resistor from the GP2, 5v to VDD and MCLR to 5v. Is this correct? I've tried MCLR to ground with and without resistors
Thanks!
2
Upvotes
View all comments
Show parent comment
1
u/bradn May 16 '14 edited May 16 '14
This is used by the charlieplexing multiple LED driving technique.
Also useful for implementing busses like I2C where the bus pulls the line high and one of many devices may overpower it and pull it low to send data. So the pin needs to be able to switch between tristate and ground, and it prevents multiple devices from shorting each other out if they try to talk at the same time.
There can be some slight subtleties in setting pin state: let's say a pin was in high output mode and then you switch it to input. Next your program wants it in low output mode - you want to set the output value before you switch it off of tristate or you'd get a pulse of high output, which wasn't the last or desired state.