EasyManuals Logo

Atmel AVR ATtiny15L User Manual

Atmel AVR ATtiny15L
85 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #29 background imageLoading...
Page #29 background image
29
ATtiny15L
1187H–AVR–09/07
The Timer/Counter1 contains two Output Compare Registers, OCR1A and OCR1B, as
the data source to be compared with the Timer/Counter1 contents. In Normal mode the
Output Compare function is operational with OCR1A only, and the Output Compare
function includes optional clearing of the counter on compare match, and action on the
Output Compare pin (PB1) (OC1A).
In PWM mode OCR1A provides the data value against which the Timer/Counter value is
compared. Upon compare match the PWM output is generated. In PWM mode The
Timer/Counter counts up to the value specified in Output Compare Register OCR1B
and starts again from $00. This feature allows limiting the counter “full” value to a speci-
fied value, lower than $FF. However, if OCR1n is $00, the output will remain constant
and not toggle at all. If OCR1n equals $01, the pulse width will be two ticks, increasing
linearly if OCR1n is larger than $01. Together with the many prescaler options, flexible
PWM frequency selection is provided. Table 14 lists clock selection and OCR1B values
to obtain PWM frequencies from 10 kHz to 150 kHz at 10 kHz steps.
In applications with variable PWM, halving the prescaler setting and doubling the duty
cycle can be used to fine-tune the PWM. Alternatively inverted PWM can be used.
The Timer/Counter1 Control
Register – TCCR1
Bit 7 – CTC1: Clear Timer/Counter on Compare Match
When the CTC1 control bit is set (one), Timer/Counter1 is reset to $00 in the CPU clock
cycle after a compare match with OCR1A Register value. If the control bit is cleared,
Timer/Counter1 continues counting and is unaffected by a compare match.
Bit 6 – PWM1: Pulse Width Modulator Enable
When set (one), this bit enables PWM mode for Timer/Counter1. This mode is described
on page 31.
Bits 5,4 – COM1A1, COM1A0: Compare Output Mode, Bits 1 and 0
The COM1A1 and COM1A0 control bits determine any output pin action following a
compare match A in Timer/Counter1. Output pin actions affect pin PB1(OC1A). Since
this is an alternative function to an I/O port, the corresponding direction control bit must
be set (one) to control an output pin. The control configuration is shown in Table 10.
Note: 1. In PWM mode, these bits have a different function. Refer to Table 12 for a detailed
description.When changing the COM1A1/COM1A0 bits, the Output Compare 1A
Interrupt must be disabled by clearing its Interrupt Enable bit in the TIMSK Register.
Otherwise an interrupt can occur when the bits are changed.
Bit 7 6 5 4 3 2 1 0
$30 CTC1 PWM1 COM1A1 COM1A0 CS13 CS12 CS11 CS10 TCCR1
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Table 10. Compare Mode Select
(1)
COM1A1 COM1A0 Description
0 0 Timer/Counter disconnected from output pin OC1A
0 1 Toggle the OC1A output line.
1 0 Clear the OC1A output line (to zero).
1 1 Set the OC1A output line (to one).

Table of Contents

Other manuals for Atmel AVR ATtiny15L

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Atmel AVR ATtiny15L and is the answer not in the manual?

Atmel AVR ATtiny15L Specifications

General IconGeneral
BrandAtmel
ModelAVR ATtiny15L
CategoryMicrocontrollers
LanguageEnglish

Related product manuals