PSoC 4 - Timer/Counter Capture Question

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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!

0 Likes
2 Replies
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here is one approach (method 2), attached.

   

 

   

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

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

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);
        
        }
   }

0 Likes