Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Noob with PIC12F683. work with Vcc from PICKIR2, always on with external power.

Status
Not open for further replies.

lachmannmarcel

Junior Member level 3
Junior Member level 3
Joined
Jan 15, 2011
Messages
29
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Romania
Visit site
Activity points
1,431
Hi.
I start playing with PIC12F683.
I mad a simple blinker(see schematics) SCHEMA PCI12F683.png
With my code (see below) when VCC is coming from PICKIT2 its wotking fine.
When my power come from external 12v my led is always ON.
Please advice. What is wrong in my schematics.



Code:
/************************************************************************
*                                                                       *
*   Processor:     12F683                                               *
*                                                                       *
*   Pin assignments:                                                    *
*   GP0 - ISCPDATA														*
*   GP1 - buton															*
*   GP2 - PWM															*
*   GP3 - MCLR															*
*   GP4 - Test Led		       	                                        *
*   GP5 - Touch	with GP1 as load	       								*							       	                                        		*
************************************************************************/
#include <htc.h>

/***** CONFIGURATION *****/
__CONFIG(
	FCMEN_OFF &  // Fail Clock Monitor Enable 
	IESO_OFF &  // Internal External Switch Over 
	BOREN_OFF &  // Brown-out detect modes 
	CP_OFF &  // Protection of data block 
	CPD_OFF &  // Protection of program code 
	MCLRE_OFF &  // Master clear reset
	PWRTE_OFF &  // Power up timer enable 
	WDTE_OFF &  // Watchdog timer enable 
	FOSC_INTOSCIO  // Oscillator configurations: internal
); 

// Define oscillator frequency
#define _XTAL_FREQ 8000000




void main(void)
{


	OSCCON = 0b01110001;	// 8Mhz INT OSC
	
	// Set up the PIC12F683 IO pins
	TRISIO = 0b00000000;	// Set all IO pins to output
	ANSEL  = 0b00000000;	// Disable analogue inputs
	//ADCON0=

	GPIO   = 0b00000000;	// Set all pins to zero
	OPTION_REG = 0b00000000;	// Set the option register (page 12 of DS)
	WPU    = 0b00000000;	// Set weak pull-up off on all pins
	CMCON0 = 7;		// Disable Comparator on 12F683


	while(1)
	{
		GP4=1; __delay_ms(1000);  GP4=0;__delay_ms(1000);
	}

}
 

This code should work.
Code:
while(1)
	{       GPIO   = 0b00000000;
		GP4=1; __delay_ms(1000);  GP4=0;__delay_ms(1000);
	}
 

This code should work.
Code:
while(1)
	{       GPIO   = 0b00000000;
		GP4=1; __delay_ms(1000);  GP4=0;__delay_ms(1000);
	}

I know that my English is not so good, but this code work when Vcc is from Pickit2. Where i remove my Pickit2 and power come from external plug(12v) led is always ON.
 

Seems like a hardware problem, have you checked the 12v connections on your hardware? And isn't the test LED in your schematic reversed?
 

Seems like a hardware problem, have you checked the 12v connections on your hardware? And isn't the test LED in your schematic reversed?

Yes 12 V is ok. In hardware my led is conected ok.
Strange thing: i put MCLR la ground(i disconected the diode 1n4148) and with external power is working. I dont understand .....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top