Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

i want to know the usage of timer (in 89s52) @ keil

Status
Not open for further replies.

thannara123

Advanced Member level 4
Joined
Jan 7, 2010
Messages
1,452
Helped
119
Reputation
238
Reaction score
110
Trophy points
1,353
Location
God's Own country India, India
Activity points
9,388
Hi experts , I want to know the usage of timer / counter (am using keil) .i had already readed the basics of timer /counter .that is TH,TL ,tmod gate etc .But i dont know how it can use please help me throug examples written i C .thank in advance
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,146
Reputation
4,298
Reaction score
2,087
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
1. write a simple program to monitor the timer interrupt and when timer interrupt occurs write an ISR routing and toggle a port pin....

or when timer overflows write a code to transmit the data...

disable the ISR and again when it enters disable the port pin which was enabled in the previous ISR routine.......

2. Write an program to transmit an data.. run the tmer and transmit the data from UART.. then when timer overflow then stop the transmission of data and again transmit the data after you exit ISR of timer...

but what you want to achieve by doing this,,,

Its better you do blinking of LED on hardware using timer interrupt...
 

thannara123

Advanced Member level 4
Joined
Jan 7, 2010
Messages
1,452
Helped
119
Reputation
238
Reaction score
110
Trophy points
1,353
Location
God's Own country India, India
Activity points
9,388
void delay() // Delay generation using Timer 0 mode 1
{
TMOD = 0x01; // Mode1 of Timer0
TH0= 0xFC; // FC66 evaluated hex value for 1millisecond delay
TL0 = 0x66;
TR0 = 1; // Start Timer
while(TF0 == 0); // Using polling method
TR0 = 0; // Stop Timer
TF0 = 0; // Clear flag
}
Any please describe the above program 's working
TMOD = 0x01; //what happens ? please explain
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,020
Reputation
4,156
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
Have you read the datasheet of your mcu?
It is the most useful thing you can read, the meaning of every register and peripheral operation is explained there.

Alex
 

thannara123

Advanced Member level 4
Joined
Jan 7, 2010
Messages
1,452
Helped
119
Reputation
238
Reaction score
110
Trophy points
1,353
Location
God's Own country India, India
Activity points
9,388
Hi finally i got .
TMOD means .It decides the source of clock for the timer. it has certain register which decide the working of timer see Ali Mazdi's text page number 255.
to take Timer we need to clear it first that is TR0 (one of the timer in 8051) ie TR0 =0000h;
in .ASM it is ,SETB TR0 .(0000h)
The timer register value counts up or increase in accordance with its machine cycle that is 0001,0010,0011 (binary)etc
atlast it will reach FFFF again it go to 0000h while the flag register will set ,so we can count TF register as a counter or else .
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top