You are on page 1of 2

COMP551 – Interfacing

Winter 2022

Lab 4

Programming PIC18 Timers

Navpreet Kaur
Student:

10270950
Student ID:

Section: 2

NOTE: Labs are due at the start of the next lab period.

Exercises:

1. Assuming the processor frequency is 20 MHz, find the lowest square wave frequency
that can be generated using Timer0 in 16-bit mode. (Calculations only, no code
needed).

Solution - Given XTMAL= 20 MHz

Timer0, 16 bit mode - 2^16 = 65536

= 65536-0

= 65536
Frequency= 1/t

t = 65536*[12/20*10^6]

= 65536*[3/5*10^6]

t= 0.0393216 sec

F lowest= 1/t = 1/0.0393216

=25.431 Hz Ans

2. Assuming the processor frequency is 20 MHz, find the highest square wave frequency
that can be generated using Timer0 in 16-bit mode. (Calculations only, no code
needed).

Solution- Given XTAL= 20MHz

Timer0, 16-bit mode = 2^16

=65536-65535

=1

t= 1*[12/20*10^6]

= 1*[3/5*10^6]

= 0.0000006 sec

F highest = 1/t = 1/0.0000006

= 1,666,666.666

= 1.66 MHz Ans

You might also like