lachmannmarcel
Junior Member level 3
- Joined
- Jan 15, 2011
- Messages
- 29
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Location
- Romania
- Activity points
- 1,431
Hi.
I start playing with PIC12F683.
I mad a simple blinker(see schematics)
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.
I start playing with PIC12F683.
I mad a simple blinker(see schematics)
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);
}
}