1 Reply Latest reply on Mar 24, 2011 12:16 AM by graa

    PSoC 1 Frequency Measurment

    chris.luteran

       Hi everyone. I'm trying to determine the frequency of a incoming signal at roughly 7KHz. This signal is correctly identified using a scope and is at correct logic levels. I am using the 16bit Tachometer digital block which adds a second interrupt. It is basically a 16 bit timer with the added interrupt. I have a 1MHz input clock which should get me enough resolution for this. The incoming frequency is fed into the capture port on the block. Now I'm having trouble getting a frequency measurement. Here is some of my code.

         

       

         

       

         
      void main(void) {  LCD_1_Start();       // Initialize LCD hardware  TachTimer16_1_WritePeriod(0xFFFF); M8C_DisableGInt; TachTimer16_1_Stop(); TachTimer16_1_EnableInt(); TachTimer16_1_Start(); M8C_EnableGInt;   while(1){      LCD_1_Position(0,0);       lcd_int(diff,5);   freq = (0.000001)*(0x10000-diff);    delay();  TachTimer16_1_WritePeriod(0xFFFF);   TachTimer16_1_Start();  delay();
         
              
         
          
      void MyCounterISRLSB(void)  //capture interrupt {  to = TachTimer16_1_wReadTimer();    if (to < tf) diff = tf-to;//(0xFFFF-tf)+to;  else diff = ((0xFFFF-tf)+to);  tf = to;      TachTimer16_1_Stop(); }
         
         
              
         
          I am getting the decimal value of 2222 for "diff" which stays consistent with the frequency at 7.3KHz but can't seem to figure out how to get this value in frequency form. I have searched hours for this and haven't gotten much of anywhere. Any help is greatly appreciated.   
         
              
        • 1. Re: PSoC 1 Frequency Measurment
          graa

          Check out the attached application note.  This is a very old application note that explains how to measure frequency with PSoC.  The project is quite old and you will have to upgrade it to the latest designer version.  While upgrading, if the new ISR files do not have the ISR code, copy them from the old ISR file which will be in the backup folder into the new files.

             

           

             

          Hope this helps.

             

           

             

          Best Regards,

             

          Ganesh