2 Replies Latest reply on Sep 6, 2015 4:29 PM by d.k..willardson

    PSoC 4 - Timer/Counter Capture Question

    d.k..willardson

      Trying to capture alternate edges and measure time difference (for MPH calc). For now, just using a delay as a hypothetical; however, the time difference is all over the place.

         

      Attached project was created for the PSoC4 - BLE Pioneer Kit and generates UART output. Any help on what I'm doing wrong would be greatly appreciated.

         

      Thanks!

        • 1. Re: PSoC 4 - Timer/Counter Capture Question
          user_14586677

          Here is one approach (method 2), attached.

             

           

             

          Note done in PSOC 5LP, change part number to PSOC 4 when you test out.

             

           

             

          Regards, Dana.

          • 2. Re: PSoC 4 - Timer/Counter Capture Question
            d.k..willardson

            Thanks for the projects. Since I was looking for alternate edge capture (Rising, then Falling edge) I ended up fiddling with my code and got it to work by moving the captures into the interrupt routine. Everything else pretty much the same. For others that may come looking....

               

             

               


            CY_ISR(InterruptHandler)
            {
                // Check interrupt source and clear Inerrupt
                InterruptHpn = Timer_GetInterruptSourceMasked();
                   if ((InterruptHpn == Timer_INTR_MASK_CC_MATCH) && (measure ==1))
                {   
                    
                    rise = Timer_ReadCapture();
                    measure =0;
                    Timer_ClearInterrupt(Timer_INTR_MASK_CC_MATCH);
                    
                }   
                else if ((InterruptHpn == Timer_INTR_MASK_CC_MATCH) && (measure ==0))
                   {   
                   
                    fall = Timer_ReadCapture();
                    measure =1;
                    Timer_ClearInterrupt(Timer_INTR_MASK_CC_MATCH);
                    
                    }
               }