PIC 12f629 cant get GP0, GP1, GP2 to go high

Thread Starter

amitr12345

Joined Jun 17, 2013
37
i have a pic 12f629 and i can't get it to go high on GPIO1 or GPIO2 or any GP for that matter.

my code is :
Rich (BB code):
#include <htc.h>        /* HiTech General Include File */
#endif
#include <stdint.h>        /* For uint8_t definition */
#include <stdbool.h>       /* For true/false definition */
#include <stdio.h>
#include <stdlib.h>
#include <pic.h>


#include "system.h"        /* System funct/params, like osc/peripheral config */
#include "user.h"          /* User funct/params, such as InitApp */
#define _XTAL_FREQ 4000000
/******************************************************************************/
/* Main Program                                                               */
/******************************************************************************/
__CONFIG(FOSC_INTRCIO & BOREN_ON & CP_OFF & MCLRE_ON & WDTE_OFF & PWRTE_OFF & CPD_OFF);
//__CONFIG(IOSCFS_4MHZ & WDTE_ON & PWRTE_ON & MCLRE_ON & BOREN_OFF & CP_OFF);

void main(void)
{    
    TRISIO = 0b000000; //GP1 LED ONLY
    INTCON = 0x0;     /* disable all interrupts */
    CMCON = 0x0;     /* turn off comparators */ tried also CMCON=0x7;
    GPIO = 0b000111;
    for(;;){;}
}
would appreciate any help ..
 
Last edited by a moderator:

Thread Starter

amitr12345

Joined Jun 17, 2013
37
No, i havent.. Is it critical to have a 10k resistor between vdd and mclr?

I checked that mclr is 5volt all the time, which means it lets the circuit run

Correct me if i am wrong?
 

tshuck

Joined Oct 18, 2012
3,534
No, i havent.. Is it critical to have a 10k resistor between vdd and mclr?

I checked that mclr is 5volt all the time, which means it lets the circuit run

Correct me if i am wrong?
Consider this your correction. MCLR us a master reset, leaving one floating is bad juju... Either connect a pull-up, or disable it in the configuration...
 

Thread Starter

amitr12345

Joined Jun 17, 2013
37
Changed mclr to off, and i will connect a pull up..

But still, is there a reason why gp0, gp1, gp2 doesnt go high?

By the way gp4 and 5 outputs 2volts...??
 

Thread Starter

amitr12345

Joined Jun 17, 2013
37
here is the last code which doesn't output to high also GP0, GP1, GP2:

Rich (BB code):
__CONFIG(FOSC_INTRCIO & BOREN_ON & CP_OFF & MCLRE_OFF & WDTE_OFF & PWRTE_OFF & CPD_OFF);

void main(void)
{
    TRISIO = 0b000000; //GP1 LED ONLY
    INTCON = 0x0;     /* disable all interrupts */
    CMCON = 0x7;     /* turn off comparators */
    GPIO = 0b111111;
    for(;;){;}
}
no schematic, because nothing is connected, just want to see high on GP2..
any new ideas ? maybe chip is damaged ?
 
Last edited by a moderator:

tshuck

Joined Oct 18, 2012
3,534
here is the last code which doesn't output to high also GP0, GP1, GP2:

__CONFIG(FOSC_INTRCIO & BOREN_ON & CP_OFF & MCLRE_OFF & WDTE_OFF & PWRTE_OFF & CPD_OFF);

void main(void)
{
TRISIO = 0b000000; //GP1 LED ONLY
INTCON = 0x0; /* disable all interrupts */
CMCON = 0x7; /* turn off comparators */
GPIO = 0b111111;
for(;;){;}
}
no schematic, because nothing is connected, just want to see high on GP2..
any new ideas ? maybe chip is damaged ?
It's entirely possible that the compiler is optimizing the for loop away, making the chip(probably) reset and reinitialize the PIC, which would mean you should see about 1/2 VDD on the outputs.... Perhaps something like:
Rich (BB code):
__CONFIG(FOSC_INTRCIO & BOREN_ON & CP_OFF & MCLRE_OFF & WDTE_OFF & PWRTE_OFF & CPD_OFF);

volatile unsigned char volatileVariable;
void main(void)
{
    TRISIO = 0b000000; //GP1 LED ONLY
    INTCON = 0x0;     /* disable all interrupts */
    CMCON = 0x7;     /* turn off comparators */
    GPIO = 0b111111;
    for(volatileVariable = 0;;++volatileVariable){;}
}
...would work...
 

Thread Starter

amitr12345

Joined Jun 17, 2013
37
Maybe i should ask in another way.

Supposed u had a pic 12f629 no circuit wired yet. U just wanted to check that gp2 goes high. In hi-tech(the code style i used), what would be your code so it would work ?
 

absf

Joined Dec 29, 2010
1,968
I changed the code a bit and it works...

Rich (BB code):
#include <pic.h>

__CONFIG (FOSC_INTRCIO & BOREN_ON & CP_OFF & MCLRE_OFF & WDTE_OFF & PWRTE_OFF & CPD_OFF);

void main(void)
{
CMCON = 0x7; /* turn off comparators */
INTCON = 0x0; /* disable all interrupts */
while (1)
{
TRISIO = 0b000000; //GP1 LED ONLY
GPIO = 0b111111;
}
}
Attached is the simulation with proteus.

Allen
 

Attachments

Thread Starter

amitr12345

Joined Jun 17, 2013
37
tried it.. tested on GP0->GP2.. the legs are not connected to anything.

shows 0.1 volts in the legs of the microcontroller.

could the chip be damaged ??
 

tshuck

Joined Oct 18, 2012
3,534
tried it.. tested on GP0->GP2.. the legs are not connected to anything.

shows 0.1 volts in the legs of the microcontroller.

could the chip be damaged ??
It's possible the chip it's damaged, but unlikely, these things can take a beating...

What programmer are you using? What us your power supply, both the voltage and the supply device?
 

Thread Starter

amitr12345

Joined Jun 17, 2013
37
I am using a 5 volt regulated power supply

Also in programming and also in burning.

Using pickit 3 with mplab ipe, mplabx compiler
 

tshuck

Joined Oct 18, 2012
3,534
I am using a 5 volt regulated power supply

Also in programming and also in burning.

Using pickit 3 with mplab ipe, mplabx compiler
MPLABX isn't a compiler... it looks like you are trying to use the Hi-Tech compiler...

Make sure your files are included in your workspace...
 
Top