PIC12F615 Level Interrupt Debugging Notes

Publisher:科技创造者Latest update time:2020-03-04 Source: eefocusKeywords:PIC12F615 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Yesterday, I was debugging a level interruption. I wanted to change the state of the LED on GP4 when GP1 was pressed. The program was done step by step. GP1 enabled weak pull-up and then connected the button to the ground line. However, when debugging on PICKit3, the LED on the PCB did not turn off. I always thought it was a problem with the code, but later I found that the power supply of PICKit3 was insufficient. It became normal after connecting 5V power. If you are afraid of trouble during debugging, you can connect a 1K~4.7K resistor to GP1 to pull it up and it can be used normally.


The relevant program codes are as follows:


unsigned char GPtemp; //level interrupt reading


void DebounceDelay(unsigned char us)

{

    while(us--);

}


void InitGPINT(void) //Level change interrupt See Datasheet page 44

{

    nGPPU=0; //The global GPPU bit must be enabled to enable the individual pull-up function.

    CMCON0=0B00000101;

    TRISIO1=1;

    AN1=0;  

    WPU1=1; //In input mode, internal weak pull-up can be set

    GPtemp=GP1;

    IOC1=1; //Enable level change interrupt        

    GPIF=0;

    GPIE=1;

}


void interrupt ISR(void) //interrupt processing function

{


/*

    if(T0IF) //timing interval 5mS

    {

        T0IF=0;

        MS++;

        PWMDelay++;

        if(MS>=200) //1 second is up.    

        {

           MS=0;

           SEC++;

           if(SEC>59)

           {

               SEC=0;

               MIN++;

           }

        }

        TMR0=T0Value; //Reassign value and enter the next cycle

    }

  */  

    if(GPIF) //level interrupt

    { 

        GPIE=0;

        GPtemp=GP1;

        DebounceDelay(255); //Debounce delay   

        if(GP1==0)

        {

            GP4=!GP4;

        }

        GPIF=0; 

        GPIE=1;

    }

    GIE=1; // Enable general interrupt

}


void main(void) 

{

    InitMCU();

    InitSW();

    InitGPINT();

    InitPWM();

    InitAD();

    InitT0();


//PEIE=1;

    GIE=1;

    

    while(1)

    {

        LEDBreathe();

    }

    return;

}

Keywords:PIC12F615 Reference address:PIC12F615 Level Interrupt Debugging Notes

Previous article:BCD code addition program for PIC microcontroller
Next article:PIC microcontroller settings configuration word information

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号