Sign In

Trouble In Timer Interrupt In PIC C Programming

sushant sushantjangale@yahoo.com India

Hardware: PIC18f6520 Pic Microcontroller Debugging With PICKit2 Software: C18 For PIC Microcontroller

hello
i am using pic 18f6520 with external crystal . i am using MPLAB IDE v8.91 with c18.
i am writing timer interrupt code but when i debugged it with pickit2 it is not entering in interrupt routine though INTCON.3 bit gets high after overflow of timer but it not entering in ISR routinte

Images

Program

#include<p18f6520.h>

#define o_display LATE    //E0=A to E7=G
#define seg_dp LATGbits.LATG1
#define o_seg1 LATGbits.LATG0
#define o_seg2 LATBbits.LATB2

void T0_ISR(void);

#pragma interrupt chk_isr  
     
  void chk_isr(void)
 {  
   if (INTCONbits.TMR0IF==1)
      T0_ISR();
  }
/***********************************************************/
  #pragma code my_int=0X08    //hight interrupt
     void my_int(void)
       {
         _asm
           GOTO chk_isr
         _endasm

       }
#pragma code
/********************************/

void main(void)
{
 
  CMCON=0X07;
   ADCON1=0X0F;

       //0 MEANS O/P D 1 MEANS I/P
   TRISF=0;
   TRISE=0;
   TRISD=0; 
   TRISB=0x33;
   TRISC=0xa3;
   TRISA=0X20;
   TRISG=0X00;


   T0CON=0X08;   //TIMER0 ,16 BIT NO PRESCALER
      // FOR 2 MIL SECOND
   TMR0H=0XFF;
   TMR0L=0XC0;
   
   
   INTCONbits.TMR0IF=0;    //CLR TF0
   
   
   
   INTCONbits.TMR0IE=0;
   INTCONbits.TMR0IE=1;    //ENABLE TIMER
   
   T0CONbits.TMR0ON=1; //START TIMER
INTCONbits.GIE=1;        //ENABLE ALL INTERRUPT GLOBALLY 
INTCONbits.PEIE=1;  
while(1);

}

/***************************************/
 void T0_ISR(void)
{
  o_seg1=0;
  o_seg2=1;
  o_display=0x01;
  TMR0H=0XFF;    // FOR 2 MIL SECOND
   TMR0L=0XC0;
  INTCONbits.TMR0IF=0;    //CLR TF0
  //T0CONbits.TMR0ON=1; //START TIMER
} 

Replies

R Avinash
2016-08-18 12:09:20
First of all you are using outdated tools. Latest is MPLABX and XC8. C18 is gone.
R sushant
2016-08-18 16:04:01
Sorry I dont have latest tools now, could you please help me with tools that i have?
R Sushant
2016-08-19 08:41:56
I do not have latest tools available for this project.
Is it possible for you to kindly help me with this project tools only?
At least it would be helpful, if you point any mistake thats been there in program.

Post a reply to sushant

Think you can help sushant ? Then post your thoughts that might help sushant. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.