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.
shepdog87
Level 3
Level 3
25 sign-ins 10 questions asked 10 replies posted

Hello,

I am using a time-stamp method of measuring a frequency of a signal. The signal is a square wave, and causes a DMA transfer to start when a rising edge is detected. There is a circular RAM buffer that holds the timestamps / counts of the timer each time the input signal has a rising edge.  A function is called periodically to subtract the counts from each other to estimate the frequency.

I used the example project from the CONSULTRON which is posted here:

https://community.cypress.com/t5/Code-Examples/Multi-Input-Frequency-Measurement-Tutorial/m-p/183038

Everything works as expected when I use the "Fixed Function" timer block with 16-bits. However, when I try changing it to a 24 or 32-bit UDB timer block, the counts do not make sense. The least-significant-byte of the RAM buffer always has the same value for some reason. When I look at the debug window for the component, the count matches what is expected in the MEMORY viewer, but it seems like the value at that address is not being transferred via DMA? 

I referenced AN61102 which shows how to transfer 32-bit values from 16-bit spokes. I added another DMA channel as an intermediate step, and from the intermediate step goes to the larger buffer.

I was using the following #define in the DMA configuration to retrieve the counts, which is 0x4000_6508: Timer_Count_COUNTER_LSB_PTR_8BIT

0 Likes
1 Solution

shepdog,

I believe I have a solution that's workable.

Below you will see a recommended Topdesign circuit.   It takes the one input from 1Hz to 5KHz and splits it simultaneously with and without Frequency prescaling.

This technique of prescaling was used in Project #8 of my tutorial.

The input frequencies of 150Hz to 5KHz are used prescaled to the lower frequencies to significantly improve the resolution you are looking for.  (At 5KHz: resolution = 0.745Hz).

The input frequencies of 1Hz to 150Hz are computed without the prescaler.  The resolution at 150Hz is 0.687Hz.

Len_CONSULTRON_0-1614270434334.png

Note: The Clk_Cnt frequency driving the Timer is 32768!   This is great.  Why?  If you use a watch crystal on the WCO inputs of the PSoC5, you get <100 PPM accuracy for your time base.   Remember:   Garbage in => Garbage out.   sub-100 PPM is not Garbage!

I hope this helps.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

7 Replies