2 Replies Latest reply on Sep 6, 2015 4:29 PM by userc_40630

    PSoC 4 - Timer/Counter Capture Question

      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.



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

          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

            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....




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