[ Log In ]
Image of the Atmega324p

Atmega324P

$8.50
Qty:
USB AVR programmer

USB AVR Programmer

$9.95
Qty:
Breadboard adapter for the USBasp AVR Programmer

USBasp Breadboard Breakout Adapter

$4.90
Qty:
Serial to USB converter with Micro USB cable

USB to Serial Converter

$10.95
Qty:
Thumbnail: Crystal Oscillator 18.432 MHz for UART

18.432 MHz Crystal Oscillator 18pf 30ppm

$0.94
Qty:
Thumbnail: 22 pF Capacitor

22 pF Multilayer Ceramic Capacitor

$0.43
Qty:
Thumbnail: Quartz crystal oscillator - 16 MHz

16 MHz Crystal Oscillator 20 pF Through Hole

$0.75
Qty:
Thumbnail: 4x4 keypad top view.

4x4 Keypad with Adhesive Backing

$3.80
Qty:
Thumbnail: quad buffer line driver 74HC126E

Quad Buffer Line Driver (Through Hole)

$0.69
Qty:
3 pin slide switch

SPDT Slide Switch 3 pin 30V

$1.49
Qty:

On Paper: Timers and Counters for AVR Microcontrollers Explained

There is an internal clock in the microcontroller. By default, this clock ticks one million times per second (1 megahertz or 1 MHz). The AVR microcontroller that you see in these videos actually ticks 8 million times per second (8 MHz), but the fuses in the microcontroller are set for an 8 prescaler to this clock. So, for every 8 ticks, the clock ticks by one.

TCNT1 is the 16-bit counter. TCNT0 is the 8-bit counter. TCNT counts with the internal clock. Of course, since these are 8 and 16 bits, TCNT cannot count up to one million, but can count up to 255 for 8 bit and 65535 for 16 bit.

You can have the timer/counter react with a signal coming in from a pin, or have it send a signal to a pin at ever set interval.

The internal clock can also be omitted and two other pins of the microcontroller XTAL can be connected to another clock source, like a crystal or a ceramic resonator. This is usually done to get a more precise clock since the internal clock has a + or - 10% error.

Comments and Additional Information

Have some code to share? Or additional information? Respond here:

You need to be logged in to save a response on this page. The response must be constructive, helpful, supplimentary or to correct the existing video, code or narrative content.

Description:

Code (optional):