AnsweredAssumed Answered

Input capture mode of MC9S12XHZ512

Question asked by KDN NANDU on Jan 6, 2015
Latest reply on Jan 7, 2015 by lama

I am using Input capture mode of MC9S12XHZ512 for calculating frequency and duty cycle of square wave from 1KHz to 10KHz , I have attached image of setting i have done in codewarrior.

 

My problem is that when I try to display frequency on my LCD display I am getting random charter on , I also have problem with interrupt input capture mode I have enable input capture mode in codewarrior , but i'm not able to find it in program , I want to write my display and calculation code in interrupt sub routine of input capture mode. I have posted my code below.

 

I'm using 16MHz crystal

 

 

LCD_Cmd(0x80);

  

                  

         //  TM=65535*(TC0/16000000);

         //  TM=1/TM;

        

         t[i]=TC0;

        

          i++;

        

          if(i==2) {

          i=0;

         

        

        

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

         time_interval=(float)(0.0000000625*time_interval);

         frequency= 1/time_interval;

      

       

  

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

 

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

         {

         LCD_Data(buffer[j]);

         }

         }

       

INPUT caputre.png

Outcomes