- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
}
}