∗ timer hotline@sarnikoff.fr ℜ(ε)+ℑ(ζ) ψΘψ Sarnikoff 2018 h=∫∞ dt WIKI EXPERIMENTAL NON SECURE OUVERT A TOUS VENTS
Microcontroleur DELAY CALCULATION of 8051 timer

Clock source:

Timer needs a clock source. If C/T = 0, the crystal frequency attached to the 8051 is the source of the clock for the timer. The value of crystal frequency attached to the microcontroller decides the speed at which the timer ticks. Now suppose that crystal frequency is 11.059MHz.

Timers clock frequency:

The frequency for the timer is always 1/12th of the frequency of the crystal attached to the 8051.
TF = 1/12 x 11.059MHz = 921583 Hz
Timers clock period:
The time delay of one machine cycle is given below. We use this to generate the delay.
TP = 1/ 921583= 1.085 µ sec
For delay of 10ms:
Firstly divide the desired time delay value (10 ms) by the timer clock period.
N= 1 / 1.085us
N= 10ms / 1.0859usec
N=9216
Subtract the value of N from the maximum number of counts possible for 16 bit timer i.e. 2^16 = 65536.
M=65536-N
M=65536-9216
M= 56320

65536 - (DRT / TIC12 * 1000)
DTR : Desire Run Time
Convert this value to hexadecimal and write in TH and TL registers.
MH=DC00H
TH=DCH
TL=00H

/***************************** C prog **************************/

#include
#define LED P1_2

void Delay(void); // Delay function declaration

void main () // main function
{
led=0; //output PORT
while(1) // infinite loop
{
LED = 1; // LED ON
Delay();
LED = 0; // LED OFF
Delay();
}
}

void Delay()
{
TMOD = 0x01; // Timer0 mode1
TH0=0xDC; //initial value for 10ms
TL0=0x00;
TR0 = 1; // timer0 start

while (TF0 == 0); // check overflow condition
TR0 = 0; // Stop Timer
TF0 = 0; // Clear flag
} hotline@sarnikoff.fr ℜ(ε)+ℑ(ζ) ψΘψ Sarnikoff 2018 h=∫∞ dt WIKI EXPERIMENTAL NON SECURE OUVERT A TOUS VENTS 27/09/21 06:25:31

∗ timer