Main Content

Count Down Through Range of Numbers

This example shows how to use the Counter block to count down through a range of numbers. The Pulse Generator block drives theDecport of the Counter block, and the N-Sample Enable block triggers theRstport. All inputs to and outputs from the Counter block are multiplexed into a single To Workspace block using a 4-port Mux block.

The following figure shows the first 22 samples of the four-column output,dsp_examples_yout.

You can see that the seventh input sample to both theDecandRstports of the Counter block represent trigger events (rising edges). When this occurs, the block first resets the counter to its initial value of5, and then immediately decrements the counter to4. When the counter reaches its minimum value of0, the block restarts the counter at its maximum value of20the next time a trigger event occurs at theDecport.

See Also

Blocks