AnsweredAssumed Answered

Input capture mode problem

Question asked by KDN NANDU on Jan 8, 2015
Latest reply on Jan 12, 2015 by KDN NANDU

I am not getting interrupt in input capture mode. I posted my code below , Please help someone

 

 

 

 

#pragma CODE_SEG __NEAR_SEG NON_BANKED

 

 

 

 

interrupt void  IC0_ISR(void)

{   

  //  new_capture = TC0;   //save the value of input capture register

   

   

    LCD_Cmd(0x80);

  

              PORTA = 0xFF;

        

         t[i]=TC0;

        

          i++;

        

          if(i==2) {

          i=0;

         

       //    6.0742270546073012209196379760675e-8

        

         time_interval=(t[1]-t[0]);

         time_period=(float)(0.0000256* time_interval);

         frequency= 1/time_period;

     

        

      

         sprintf(buffer,"%f",frequency);

 

 

         for(j=0;j<4;j++)

         {

         LCD_Data(buffer[j]);

         }

   

}

   TFLG1 = 0x01;       //clear interrupt flag  

 

 

}

 

 

 

interrupt void  TOI_ISR(void)

{

  

   

    TFLG2 = 0x80;       //clear interrupt flag

}

 

 

 

 

 

unsigned int TM;

 

 

/* User includes (#include below this line is not maintained by Processor Expert) */

 

 

void main(void)

{

  /* Write your local variable definition here */

 

 

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

 

 

  /* Write your code here */

 

 

        LCDIni();

  

//   LCD_Cmd(0x01);

   LCD_Cmd(0x80);

  

   LCD_Data('T');

 

  

 

 

 

    PPST_PPST0 = 0;  //set pull-up

    PERT_PERT0 = 1;  //enable pull-up   

 

   TSCR1 = 0xE7;       //enable timer, stop timer during wait and freeze, disable fast flag clear

   TIOS_IOS0 = 0;      //channel 0 as an input capture

    TCTL4 = 0x01;       //capture on rising edge

    TIE_C0I = 0x01;        //enable interrupt on channel 1   

    TSCR2 = 0x80;       //timer overflow interrupt enable, timer prescaler is 0

 

 

 

 

 

 

 

 

 

 

 

  for(;;){}

  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

 

 

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

Outcomes