arduinoarduino-unoatmega

Which Arduino Uno pin corresponds to TCNT0?


I am trying to count using the internal ATMega328 to create a Theremin based on this concept. I am using the internal timer1 and timer0 counters. However, I am unable to find documentation for which pin to use as an input to trigger the corresponding counter increase.

Pin 5 corresponds to TCNT1, which pin corresponds to TCNT0?


Solution

  • TCNT1 and TCNT0 are both timer registers in the microcontroller. Neither is associated with any pin at all unless you write timer-based code or timer interrupts that interact with input or output pins. You need to study the Atmel datasheet for the ATmega328. All registers and use of the timers are covered in detail. The design you refer to doesn't appear to use Timer0 at all.

    Example:

    "Registers The Timer/Counter 0 register (TCNT0) and Output Compare TC0x registers (OCR0x) are 8-bit registers. Interrupt request (abbreviated to Int.Req. in the block diagram) signals are all visible in the Timer Interrupt Flag Register 0 (TIFR0). All interrupts are individually masked with the Timer Interrupt Mask Register 0 (TIMSK0). TIFR0 and TIMSK0 are not shown in the figure."

    "The Timer/Counter (TCNT1), Output Compare Registers (OCRA/B), and Input Capture Register (ICR1) are all 16-bit registers. Special procedures must be followed when accessing the 16-bit registers. These procedures are described in section Accessing 16-bit Registers."