1.25.23.32 TCx_QuadratureSpeedGet Function

C

/* x = TC instance number */

/* 16 bit counter */
uint16_t TCx_QuadratureSpeedGet ( void )

/* 32 bit counter */
uint32_t TCx_QuadratureSpeedGet ( void )

Summary

Reads the quadrature index change speed.

Description

This function reads the number of quadrature pulses captured in timer channel for given time base.

Precondition

TCx_QuadratureInitialize function must have been called first for the given channel.

Parameters

None

Returns

Number of quadrature pulses counted in given time base which is used to determine speed of motion tracked by the encoder. Type of the return value varies with the bit width of the counter.

Example

16 bit counter

uint16_t speed;
TC0_QuadratureInitialize();
TC0_QuadratureStart();
speed = TC0_QuadratureSpeedGet();

32 bit counter

uint32_t speed;
TC0_QuadratureInitialize();
TC0_QuadratureStart();
speed = TC0_QuadratureSpeedGet();

Remarks

Caller must calculate the actual speed based on returned speed count value, time base and number of quadrature encoder pulses.