Jump to main content

##

# 2.120.2.30 TCx_QuadraturePositionGet Function

## C

    /* x = TC instance number */

    /* 16 bit counter */
    int16_t TCx_QuadraturePositionGet ( void )

    /* 32 bit counter */
    int32_t TCx_QuadraturePositionGet ( void )

## Summary

Reads the angular position from the quadrature encoder.

## Description

This function reads the position 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

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

## Example

16 bit counter

    int16_t position;

    TC0_QuadratureInitialize();
    TC0_QuadratureStart();
    position = TC0_QuadraturePositionGet();

32 bit counter

    int32_t position;

    TC0_QuadratureInitialize();
    TC0_QuadratureStart();
    position = TC0_QuadraturePositionGet();

## Remarks

In counter-clockwise direction, position counter works in down counting mode.