Read pulse count from a MP line in SigmaStudio v4.6 for ADAU1452
Hi Support,
We are using ADAU1452 and SigmaStudio v4.6.
Which algorithms are needed in order to read an input pulse counts from a MP line?
regards,
ping
Audio Signal Processors
adau1452
adau1452 sigmastudio
SigmaDSP Audio Processors
Hello Ping,
There is a block in the Counters section that is called a "Pulse Counter", but it is not really a pulse counter. It simply counts how many sample periods a pulse is high. In the GPIO Conditioning section of the library there is a "Toggle Counter". This works well but it only counts up to a specified value then wraps back around to zero. You cannot reset it easily. The way to reset it to zero is to put in a new value into the count that is less than the current count.
The min value is 3 so if the counter is 2 it will not reset even if you place a zero into it. However, this is the GUI code doing that. If you stuff a Zero directly into the parameter bypassing SigmaStudio it will reset the counter and it will stop counting until a non-zero value is placed into the parameter.
So the DSP code works well,
Count set to zero, it does not count, output stays zero.
Count set to One, it does not count, output stays zero.
Count set to Two, it counts 0, 1, then back to 0.
Count set to Three, it counts 0,1,2, then back to 0.
So if you have a controller you can easily control this and count pulses. If you do not have a controller then using Parameter Write blocks would need to be used and that is another topic of discussion so I will not cover it here at the moment.
Here is a test program as an example.
ADAU1452 GPIO Pulse length and pulse toggle counter.dspproj
Dave T
Hi Ping,
Dave's suggestions are excellent. I'd like to also mention the Rising Edge detector, which when combined with a Pulse Counter, may present a simple solution.
The Rising Edge detector is actually called "OneShot Rise with Reset" but when the output is fed back to the Reset input, of course with 1 sample delay built into the feedback, it will trigger on each rising edge.
Joshua
Thanks Josh,
I updated my example file to show the third way to do it. They all have slight differences and depending on the final application one may be better than another. This just goes to show what we always say that there is often so many ways to solve problems with the standard blocks.
So here is the updated example file.
5226.ADAU1452 GPIO Pulse length and pulse toggle counter.dspproj
Dave T
Hi Dave and Josh,
Thanks for your supports.
Let me try to implement your suggestions in real design block but please help during these tries.
regards,
ping
Please log in to reply.