TCNTOUT() returns the accumulated upper overflow value in 32-bit extension mode.
uint16_t TCNTOUT(uint8_t timerNumber)
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
TCNTOUT(timerNumber) | uint8_t timerNumber — External clock timer number supported by the product | uint16_t | Returns the accumulated upper overflow value in 32-bit extension mode. |
const uint8_t COUNTER_TIMER = 1; void setup() { Serial.begin(115200); TCNTSETUP(COUNTER_TIMER, true); // Configure the timer's external clock input and 32-bit extension mode. } void loop() { static uint16_t previousOverflow = 0; const uint16_t overflowCount = TCNTOUT(COUNTER_TIMER); // Return the accumulated upper overflow value in 32-bit extension mode. if (overflowCount != previousOverflow) { previousOverflow = overflowCount; Serial.println(overflowCount); } }
TCNTOUT() as a simple function for reading the current 16-bit counter.