CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to program PIC 12F629 ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mmc01



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

How to program PIC 12F629 ?
PostPosted: Mon Jul 21, 2014 11:16 pm     Reply with quote

I program to 12F629. It have GP0-GP5. I can't use the code like this. 12F629 should use internal clock. I want to use microcontroller for 5 PIN only. What the number of microcontroller PIC suitable for me ? How to program PIC 12F629 ?
Code:

void main (void)
{

  while(TRUE){
     
     if(!input(GP0)){
         output_high(GP2);

         delay_ms(500);
     }

   }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19559

View user's profile Send private message

PostPosted: Mon Jul 21, 2014 11:36 pm     Reply with quote

Post the rest of your code. The processor setup etc..
These are what define which pins you can use.

The only PIC's with 5 I/O pins or more, are the 8 pin PIC's like the 629, so stick with what you have.

Programming it depends on what programmer you have?.
Code:

#include <12F629.h>
#FUSES NOWDT, INTRC_IO, NOMCLR, NOBROWNOUT
#use delay(INTERNAL=4000000)

void main()
{
   setup_comparator(NC_NC);
   output_low(GP2);
   while(TRUE)
   {
       if(!input(GP0))
       {
            output_high(GP2);
            delay_ms(500);
            output_low(GP2); //you needto lower the line again
            //or it'll stay high forever...
       }
   }



This is the 'example' program with fuses and clock, to give 5 general purpose I/O lines, and one input only line on GP3.
Note also that you have to pull GP2 low before and after you pull it high, or it'll just stay high forever.
mmc01



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

PostPosted: Tue Jul 22, 2014 12:47 am     Reply with quote

when I compile it show error like this. How to use 12F629 with CCS ?

Quote:
Error 12 "main.c" Line 8(15,18): Undefined identifier GP2
Error 12 "main.c" Line 11(18,21): Undefined identifier GP0
Error 12 "main.c" Line 13(25,28): Undefined identifier GP2
Error 12 "main.c" Line 15(24,27): Undefined identifier GP2

4 Errors, 0 Warnings
Ttelmah



Joined: 11 Mar 2010
Posts: 19559

View user's profile Send private message

PostPosted: Tue Jul 22, 2014 12:52 am     Reply with quote

I used the names you used in your code. You must have them defined somewhere. Your definitions need to be added if you are using your own names. The standard names are PIN_A0 to PIN_A5 (for current compilers).
mmc01



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

PostPosted: Thu Jul 24, 2014 8:16 pm     Reply with quote

The standard name of 12F629 different from 16F.

http://ww1.microchip.com/downloads/en/devicedoc/41190c.pdf

I'm not sure what is standard name of 12F629. Can I use 12F629 with PIN_A0 to PINA5 ?
dyeatman



Joined: 06 Sep 2003
Posts: 1938
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Jul 24, 2014 8:40 pm     Reply with quote

From the 12F629 CCS header file:
Quote:
// Constants used to identify pins are:

#define PIN_A0 40
#define PIN_A1 41
#define PIN_A2 42
#define PIN_A3 43
#define PIN_A4 44
#define PIN_A5 45

_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 25, 2014 12:11 am     Reply with quote

If you want to use the "GP" names for the pins, just add this code above main():
Code:

#define GP0   PIN_A0
#define GP1   PIN_A1
#define GP2   PIN_A2
#define GP3   PIN_A3
#define GP4   PIN_A4
#define GP5   PIN_A5
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group