Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

very stupid request for pic12f510

Status
Not open for further replies.

picozero

New Member
So,
I am new of pic but this should be very easy.
Equipment:
-PICKIT2 as a programmer
-HI-TECH PICC as a compiler fo C code
-PIC12F510 as microcontroller

I'd like to simply turn on a led, because if I am not capable of this, then the rest is impossible.

The pic looks like this:
**broken link removed**
Obviously I connect 5V to Vdd and pin8 to ground, no external oscillator/clock.
And I connect e led (with a resistor before) to GP1.

Here is the code:
Code:
#include <htc.h>
__CONFIG(MCLREN & UNPROTECT & WDTDIS  & INTOSC);

void main() 
{
     TRIS = 0;//0b111101;
     GP1  = 1;
     for(;;)
        { ; }
};

I don't see anything in the output except some 1 volt (I see even if I erase the code, therefore is not due to my code).

The HITECH CODE generates many files, HEX, COF..... without error or warning
(so it seems so fare it is ok).

Then I run MPLAB IDE and "import the HEX file" into an empty project. Select PICKIT 2 as a programmer, press "program". No error from MPLAB


Anything wrong in the process somewhere?
 
You need to make the pins digital (they default to analogue) with ADCON0 = 0;

You should also be able to have the code in MPLAB and then compile and download automatically.

Edit, you also need to tie MCLR high.

Mike.
 
Last edited:
Is it better now? :

Code:
#include <htc.h>
__CONFIG(MCLREN & UNPROTECT & WDTDIS  & INTOSC);

void main() 
{
     ADCON0 = 0;
     TRIS = 0; 
     GP1  = 1;
     for(;;)
        { ; }
};

MCLR is already enabled in the __Config macro, if I write MCLR = 1; I get an error
 
Nope, no life.
I was only capable to integrate the Hitech compiler in mplab
but I just noticed two things, :

1. This is the output of the MPLAB :

Initializing PICkit 2 version 0.0.3.63
Found PICkit 2 - Operating System Version 2.32.0
Target power not detected - Powering from PICkit 2 ( 5.00V)
PICkit 2 Ready
Programming Target (10-02-2011 14:25:17)
Erasing Target
Programming Program Memory (0x0 - 0x7)
Programming Program Memory (0x1FA - 0x1FF)
Verifying Program Memory (0x0 - 0x7)
Verifying Program Memory (0x1FA - 0x1FF)
Programming Configuration Memory
Verifying Configuration Memory
PICkit 2 Ready

If you look at the third row it says: "Target power not detected - Powering from PICkit 2 ( 5.00V)" I think it is ok, but let me know if it is fishy.

2. Then I realized that MPLAB is uploading in the pic the .cof file not the .hex file
 
Status
Not open for further replies.

Latest threads

Back
Top