The 8051 Microcontroller and Embedded

(lily) #1
Department of Computer Scien

ce and Information Engineering

National Cheng Kung University, TAIWAN
HANEL
PROGRAMMING TIMERS IN CTimes 0/1 Delay Using Mode 1 (16-bit Non Auto-

reload) (cont’)


Example 9-25.....void T0M1Delay(unsigned char c){TMOD=0x01;if (c==0) {


TL0=0x67;TH0=0xFC;} else {TL0=0x9A;TH0=0xFD;} TR0=1;while (TF0==0);TR0=0;TF0=0;
}

FC67H = 6461565536 – 64615 = 921 921 ×

1.085

μs = 999.285

μs

1 / (999.285

μs ×
2) = 500 Hz
Free download pdf