![FTDI FT51A Application Note Download Page 123](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158123.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
122
Copyright © 2015 Future Technology Devices International Limited
2.13.15.1
Timers
Below is a comparison of steps necessary to setup a standard 8051 Timer 0 versus the FTDI Timer
A.
Standard 8051 Timer 0
//Set the Timer 0 prescaler to 0 (0
–
divide-by-12, 1
–
divide-by-4)
//Note: CKCON bit 3 relates to Timer 0, bit 4 Timer 1
CKCON
&= 0xF7;
// Set timer control mode, either timer mode, counter mode or UART mode.
TMOD
&= 0xF0;
TMOD
|= 0x01; //select timer mode 1, 16-bit timer THx and TLx are cascaded.
//Preload high and low timer value
TH0
= 0xAA;
TL0
= 0xAA;
//Enable interrupts
IE
&= 0x7D;
//Timer control
TCON
&= 0xCF; //reset
TCON
|= 0x10; //run
while((
TCON
& 0x20) == 0); //loop until timer overflows
TCON
&= 0xCF; // stop