Gpio not turning high in led blink program

Thread Starter


Joined Jan 19, 2022
Hi all iam new to pic12f675.trying to implement led blink program
But Gpio not turning high
kindly review the code below and please guide

MOD: Please use Code Tags.

#pragma config FOSC = INTRCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN)

#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)

#pragma config PWRTE = OFF // Power-Up Timer Enable bit (PWRT disabled)

#pragma config MCLRE = ON // GP3/MCLR pin function select (GP3/MCLR pin function is digital I/O, MCLR internally tied to VDD)

#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)

#pragma config CP = OFF // Code Protection bit (Program Memory code protection is disabled)

#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)

#include <xc.h>

#define _XTAL_FREQ 4000000

void main(void) {

TRISIO = 0x00;//set led as o/p

ANSEL = 0x00;//for setting digital i/o

CMCON = 0x07;

VRCON = 0x00;

ADCON0 = 0x00;

GPIO = 0;




GP2 = 1;// setting port as 1


GP2 = 1;// setting port as 1


Last edited by a moderator:


Joined Jun 4, 2014
GP2 is a totem pole output so it should work.
Remove the 'return' in the while loop - 'main' in embedded programs should not return. I don't know what it would do if it does hit a return.


Joined Jan 8, 2017
I am VERY poor at "C" programming but it looks to me that GP2 is only set high. Either line 41 or line 45 should be changed
to GP2 = 0;// setting port as 0
Show us how the LED is connected to GP2. Is the end not connected to GP2 connected to 0 volts or +5 volts. Is it the anode or cathode that is connected to GP2. (NOTE there should be a current limiting resistor in series with the LED.)
Note It is GP3 (Pin 4) that is open collector.