1.8.22.31 1.25.23.31 1.26.20.31 1.27.23.31 1.28.25.31 1.34.23.31 1.35.16.31 1.36.18.31 1.41.21.31 1.42.20.31 TCx_QuadratureRevolutionsGet Function

C

/* x = TC instance number */

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

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

Summary

Reads the number of revolutions from the quadrature encoder.

Description

This function reads the number of revolutions from the quadrature encoder by reading as tracked by the channel counter.

Precondition

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

Parameters

None.

Returns

Number of revolutions of the encoder. Type of the return value varies with the bit width of the counter.

Example

16 bit counter

int16_t revolutions;

TC0_QuadratureInitialize();
TC0_QuadratureStart();
revolutions = TC0_QuadratureRevolutionsGet();

32 bit counter

int32_t revolutions;

TC0_QuadratureInitialize();
TC0_QuadratureStart();
revolutions = TC0_QuadratureRevolutionsGet();

Remarks

In counter-clockwise direction, revolution counter works in down counting mode. This function is available only if quadrature encoder provides index pulse.