Sample code for PIC12F629/675 processors

Sample code for PIC12F629/675 processors that demonstrates how to initialize and use gpio port, interrupts and register mapped variables (variables with fixed addresses).
(To use with the C2C compiler version 4.1.5 or higher)


//This sample program for the PIC12F629 target
//(for PIC12F675 uncomment the 'ansel' vaiable)
//shows how to use interrupts and register mapped
//variables (variables with fixed addresses).

char option@0x81;
char trisio@0x85;
char gpio@0x5;
char intcon@0x0B;
char cmcon@0x19;

//char ansel@0x9F;

char led = 1;

void interruptvoid )
{
    if( led )
    {
        gpio = 7;
        led = 0;
    }
    else
    {
        gpio = 0;
        led = 1;
    }

    intcon &= 0xFB;
}

main()
{
    option = 3;    //set prescaler to 1:16
    trisio = 0;    //set all IOs to output
    //ansel = 0;
    cmcon = 7;    
    gpio = 0;

    intcon = 0xA0;    //enable GIE & TMR0 interrupt

    while( 1 ); //endless loop
}

/*
    EOF
*****************/
 



Copyright© 2002 Pavel Baranov