User Tools

Site Tools


en-us_commands:reference:tcntsetup

This is an old revision of the document!


TCNTSETUP()

TCNTSETUP() configures timer external clock input and 32-bit extension mode.

TCNTSETUP command operation flow

void TCNTSETUP(uint8_t timerNumber, bool on32bit = false)

Commands

Command Arguments Return Value Operation
TCNTSETUP(timerNumber, on32bit) uint8_t timerNumber — External clock timer number supported by the product
bool on32bit = falsefalse: use only the hardware 16-bit counter. true: accumulate the upper 16-bit overflow count using overflow interrupts
void Configures timer external clock input and 32-bit extension mode.

Example

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);
  }
}

Precautions

  • Timer external clock mode is supported only by MPINO-8A8R and MPINO-16A8R8T.
  • Even on supported products, verify TCNT terminals and timer numbers using product documentation.
  • Do not interpret TCNTOUT() as a simple function for reading the current 16-bit counter.
  • In interrupt ISRs on other products, perform no work other than incrementing the count.

← Built-in Command List

en-us_commands/reference/tcntsetup.1788791736.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki