Discussion in "8051 Discussion Forum" started by    joepotter    Nov 24, 2010.
Wed Nov 24 2010, 09:13 PM
#1
Hi
I want to make an Interrupt with 1 seconde delay. I dont know how I can setup the THO, and TL0 values .
The timer : 65536 -(1seconde/1,852micro-seconde) is negativ .
How I can resolve this problem. ??

Thanks
Wed Nov 24 2010, 09:44 PM
#2
This is a common question.
Set a timer to interrupt at 50mS intervals.
Count 20 interrupts and you have one second.

Look for similar posts in the 8051 forum and you will find code examples.
 joepotterbagusdj like this.
Thu Nov 25 2010, 05:33 AM
#3
hi joepotter
see this


general formula for timer is

(65536-xx)*machine cycle= delay u want
where xx is a 16 bit no having value of TH0 and TL0

when timer run in 16 bit mode with 11.0592 mhz max delay
that can be generated is 72 ms almost.

now let say u use 12MHz crystal then Machine cycle is calculated
as for every crystal value


(crystal value / 12)= frequency

(1 / frequency) = Machine cycle

now for 12 MHz
12 Mhz/12= 1MHz
( 1 / 1MHz ) = 1us

(65536-xx)*1us= 50 ms
(65536-xx)=50,000
xx=15536
in hex it is
xx=0x3CB0
U can use window calculator for conversion from decimal to hexadecimal
now
TH0=0X3C
TL0=0XB0


it generate a 50 ms delay @ 12 MHz crystal
declare a variable and enable timer interrupt increment counter on each interrupt after 50 ms
when count=20 it means delay is 1 sec
20*50ms=1000ms=1sec
sample code
#include<reg51.h>

unsigned char count;
void timer () interrupt 1
{
  TH0=0X3C;
  TL0=0XB0;
  count++;
}
void main (void)
{
count=0;
  TMOD=0X01;
  TH0=0X3C;
  TL0=0XB0;
  IE=0X82;      // enable timer 0 interrupt 
  TR0=1;          //run timer 0
while (1)
{
if (count==20)
count=0;
// it mean delay is 1 sec
}
}


[ Edited Thu Nov 25 2010, 05:41 AM ]
Tags 8051 timer8051 timer calculationtimer example 8051

Get Social

Information

Powered by e107 Forum System

Conversation

Sat Oct 24 2020, 11:19 PM
Rosalina
what is an outline of an essay https://essaywritinget.com - buying an essay online technology essays editing the essay where to buy essays comparative essay
Sat Oct 24 2020, 11:44 AM
Rene Derham
It’s only because he's a world-class copywriter, that he can hand you these done-for-you campaigns.
Thu Jun 11 2020, 06:27 AM
anudee
sir could please send the code for I2C and wifi interfacing with 8051
scena
Tue May 19 2020, 10:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 07:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 01:39 PM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 10:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 12:55 PM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 05:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 04:58 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 90, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123