Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ET4640 Embedded Systems 2. What is the lowest frequency that can be generated on

ID: 1716041 • Letter: E

Question

ET4640 Embedded Systems

2. What is the lowest frequency that can be generated on Timer0 using:

a. 16-bit mode

b. 8-bit mode if the crystal frequency is 10 MHz? Show your calculation.

3. What is the lowest frequency that can be generated using Timer1 if the crystal frequency is 10 MHz? Show your calcula±on.

4. Compare and contrast the features of Timer0, Timer1, and Timer2.

5. In 16-bit mode, when is TMR0IF set to high? State to which register TMR0IF belongs to.

6. In 8-bit mode, when is TMR0IF set to high?

Explanation / Answer

a. Lets assume That XTAL = 20MHz & a square wave of 0.5kHz.

Now programming

1/0.5K=.002/2=.001/(12/20M)=1666.67

65536-1666.67=63869.4=F97D

MOV TMOD, #01H

MOV TH0, #0F9H

MOV TL0, #7DH
1/(20MHz/12)= .6 usec

T=1/f=1/0.5e3=.002 thats for a full wave so we then divide that by half .002/2=.001

.001/1.085e-6=921.6589862 .001/.6e-6=1666.67

65536-921.6589862=64614.34101=FC66 65536-1666.67=63869.33=F97D

MOV TMOD, #01H ;TIMER 0 MODE 1

HERE:     MOV TL0, #66H #7DH

MOV TH0, #0FCH #0F9H

CPL P1.5

ACALL DELAY

SJMP HERE,nv mn A

DELAY:    SETB TR0                                   

AGAIN:     JNB TF0, AGAIN

CLR TR0

CLR TF0

RET

B.8-bit mode if the crystal frequency is 10 MHz

Soln ;- Clock Frequency = crystal oscillator/12

                                     = 10/12 =833msec.

4.Comparison of the features of Timer0, Timer1, and Timer2.

PIC Timer0

The Timer0 module timer/counter has the following features:

PIC Timer1

The Timer1 module, timer/counter, has the following features:

PIC Timer2

The Timer2 module, timer/counter, has the following features:

3. 8-bit mode if the crystal frequency is 10 MHz

Assume that XTAL = 20MHz

MOV TMOD, #10H

MOV TH1,

T= 1/f = 1/10e3 = 0.0001   ;50 microsec

50e-6/(12/20e6) = 50e-6/0.6e-6 = 83.33

65536 - 83.3 = 65454 (rounded up) = FFAE

MOV TMOD, #10H Timer 1 Mode 1

MOV TL1, #AEH

MOV TH1, #FFH

5.In 16-bit mode, when is TMR0IF set to high? State to which register TMR0IF belongs to.

TMR01F is set to high when TMR0L rolls over from 0xFF to 0x00. and TMR01F belongs to an intrupt overflw indication.

6. In 8-bit mode, when is TMR0IF set to high?

TMR01F is set to high when TMR01l rolls over from 0xFF t 0x00.