0% found this document useful (0 votes)
50 views5 pages

TIMERS

The document discusses different timer modes and configurations for timers 0 and 1 on an ATmega328p microcontroller. It provides equations to calculate timing parameters like frequency and duty cycle for common timer modes including normal, PWM phase correct, CTC, and fast PWM. Examples are given of configurations with different prescaler and comparator register values to achieve specific frequencies and duty cycles.

Uploaded by

Reynaldo Hurtado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views5 pages

TIMERS

The document discusses different timer modes and configurations for timers 0 and 1 on an ATmega328p microcontroller. It provides equations to calculate timing parameters like frequency and duty cycle for common timer modes including normal, PWM phase correct, CTC, and fast PWM. Examples are given of configurations with different prescaler and comparator register values to achieve specific frequencies and duty cycles.

Uploaded by

Reynaldo Hurtado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 5

VALORES PRES PRE FOSC TC TCNT0 TC TCNT0

1 1 16000000 0.000016 0 1us 494


8 10us 350
64 32us 0
256 20us 190
1024

T = 1/FOSC T
6.25E-08
TC = T*PRE*(510-TCNT0) TC
0.000032

TCNT0 = 510 - TC/(T*PRE) TCNT0


254
NO POSIBLE
NO POSIBLE
F_CPU 16000000 F en Hz T en ms
NORMAL MODE: FC=F_CPU/(PRE*OCR0A)
Fmin Fmax PRE Fw OCR0A Tw
61.0351563 15625 1024 50 312.5 20
Tmin Tmax
0.064 16.384
CD =(OCR0A-OCR0B(/OCR0A*100
OCR0B DC
250 20

PWM PHASE CORRECT TOP 255: FPWM=F_CPU/(PRE*510): OCR=DUTY*255/100


Fmin Fmax PRE FPWM DUTY OCR(no inver)
30.6372549 31372.54902 1024 30.637254901961 40 102
Tmax Tmin TPWM
32.64 0.031875 32.64

PWM PHASE CORRECT TOP OCRA: FPWM=F_CPU/(PRE*510): OCR=DUTY*255/100


Fmin Fmax PRE OCRA FPWM DUTY
30.6372549 7812.5 1024 156 50.080128205128 10
Tmax Tmin TPWM
32.64 0.128 19.968

CTC: FW = F_CPU/(2*PRE*(1+OCRnx); OCR0A = F_CPU/(2*PRE*Fw) – 1; OCR0B=DC*OCR0A/100


Fmin Fmax PRE OCROA OCROB Fw
30.5175781 7812.5 1024 156.25 31.25 100

FPWM(modo 3)=F_CPU/(PRE*256); DC = OCR0nx*100/256


Fmin Fmax PRE Fpwm OC0Rnx DC
61.0351563 62500 64 976.5625 64 25

FPWM(modo 7)=F_CPU/(PRE*OC0Rnx); DC = OCR0A*100/256


Fmin Fmax PRE Fpwm Tpwm OCR0A
500 512000 1024 500 2 31.25

TIMER1: Fw = F_CPU/(PRE*(1+TOP)); ICR1(TOP) = F_CPU/(PRE*Fw) - 1; OCR1nx=DC*100/(TOP+1)-1


FW PRE ICR1 (TOP) DC (OC1A) OCR1A DC (OC1B)
50 8 39999 25 9999 75
OCR(inver)
153

OCRB(no inver) OCRB(inver)


15.6 140.4

1; OCR0B=DC*OCR0A/100 https://www.youtube.com/watch?v=goWCAIsAhGc&list=PL5a8rjiFubvetVKc8T
Tw DC
10 20

*100/256 https://wolles-elektronikkiste.de/en/timer-and-pwm-part-2-16-bit-timer1
OCR0B DC https://www.ee-diary.com/2021/07/atmega328p-fast-pwm-mode-programm
15.625 50

00/(TOP+1)-1
OCR1B
29999
st=PL5a8rjiFubvetVKc8T-bHUXx6KZXm6XkA&index=26

part-2-16-bit-timer1
-pwm-mode-programming.html

You might also like