cancel
Showing results for 
Search instead for 
Did you mean: 

DAVE™

User22913
New Contributor
Hello all,

I am using DAVE CAPTURE_GetPeriodInNanoSec to measure the period of a signal. I am calling that function every 2 ms (500 Hz). When the signal frequency drops below about 250 Hz the status code from CAPTURE_GetPeriodInNanoSec is always CAPTURE_STATUS_NEW_VAL_NOT_CAPTURED. I believe this is because the CAPTURE_GetPeriodInNanoSec is looking for both a rising and falling edge between calls and at input signal frequencies below half of the capture calling frequency that will never happen.

I have modified CAPTURE_GetPeriodInNanoSec such that it only returns CAPTURE_STATUS_NEW_VAL_NOT_CAPTURED if neither a rising nor falling edge was captured. This seems to do what I want. Does anyone have any insight into this?

Another possible solution is to call CAPTURE_GetPeriodInNanoSec at a lower frequency, but that makes it harder to use the filter that I would like to when my signal goes into a higher frequency range.

PS: the reason I need to use the return code at all is to detect when the frequency of my signal suddenly drops to zero. In those cases I expect to get CAPTURE_STATUS_NEW_VAL_NOT_CAPTURED returned and I can use that to know that the frequency is now zero.
0 Likes
1 Solution
User22913
New Contributor

I guess I was misunderstanding the way this function works. I was expecting I could call it at a higher frequency and though I wouldn't see a complete period between two calls, I would eventually get the whole period after a few calls depending on the signal frequency, but I think that would rely on somehow manually clearing the capture flags, which I'm guessing is currently done when the capture status register is read and it might not be possible to change that.

What is happening with the change that I made is if either signal edge is detected then the full period is updated and returned because the two halves of the period are stored in the capture registers even if there has not been a new capture. So basically I am getting a new period value on every rising and falling edge which I think is ok. I understand this is hard to explain and I might not be doing a good job, but I feel comfortable now that the change I made is doing what I want and will work for me.

Thanks for the help!

View solution in original post

0 Likes
3 Replies
ncbs
Moderator
Moderator

Hi @User22913,

Could you confirm if you are using CCU4 block?

Also, could you share the configurations set by you for the timer block?

 

Regards,
Nikhil

 

0 Likes
Andreas_Heder
New Contributor II

Hey,

if your target frequence is lower than your "calling" frequence from CAPTURE_GetPeriodInNanoSec is the return value correct, because there was no new complete period captured. 

 

one solution could solve this problem: try to get the Timer Status-->

with (CAPTURE_GetTimerStatus(&CAPTURE_0)) and call the 
(CAPTURE_GetPeriodInNanoSec (&CAPTURE_0, &signal_period) only when the timer is in idle mode.
 
I have not tested this, but it should work.
 
Best Regards
Andreas
0 Likes
User22913
New Contributor

I guess I was misunderstanding the way this function works. I was expecting I could call it at a higher frequency and though I wouldn't see a complete period between two calls, I would eventually get the whole period after a few calls depending on the signal frequency, but I think that would rely on somehow manually clearing the capture flags, which I'm guessing is currently done when the capture status register is read and it might not be possible to change that.

What is happening with the change that I made is if either signal edge is detected then the full period is updated and returned because the two halves of the period are stored in the capture registers even if there has not been a new capture. So basically I am getting a new period value on every rising and falling edge which I think is ok. I understand this is hard to explain and I might not be doing a good job, but I feel comfortable now that the change I made is doing what I want and will work for me.

Thanks for the help!

View solution in original post

0 Likes
Top labels