1.25.23.6 TCx_CHy_TimerCounterGet Function

C

/* x = TC instance number, y= channel number */

/* 16 bit timer */
uint16_t TCx_CHy_TimerCounterGet ( void );

/* 32 bit timer */
uint32_t TCx_CHy_TimerCounterGet ( void );

Summary

Reads the timer channel counter value

Description

This function reads the timer channel counter value.

Precondition

TCx_CHy_TimerInitialize() function must have been called first for the given channel.

Parameters

None

Returns

The timer's counter value. Type of the return value is different based on the timer bit width.

Example

16 bit timer

uint16_t counter;

TC0_CH2_TimerInitialize();
TC0_CH2_TimerStart();
counter = TC0_CH2_TimerCounterGet();

32 bit timer

uint32_t counter;

TC0_CH2_TimerInitialize();
TC0_CH2_TimerStart();
counter = TC0_CH2_TimerCounterGet();

Remarks

None