how to use timer1 of 8051 as counter

3 replies [Last post]
ankit
User offline. Last seen 50 weeks 5 days ago. Offline
Joined: 03/24/2009
bOt Points: 123

i wish to use timer1 of 8051 as a counter
i am using AT89S52 & i use assembly language

bOtskOOl
User offline. Last seen 19 weeks 2 days ago. Offline
Joined: 02/21/2009
bOt Points: 3496
Using timer1 as a counter
  • P3.5 (pin15) is used to count pulses for timer1
  • C/T=1 for using timer1 as a counter
Consider the example below. Here we are using the timer1 in mode 2 and it is acting like a counter.

 

MOV  TMOD,#01100000B     ;this sets the  timer1 in mode2 & as counter 

Instructions for starting or stopping the counter are same as that in case of timer.

 

ankit
User offline. Last seen 50 weeks 5 days ago. Offline
Joined: 03/24/2009
bOt Points: 123
thanks

 
but i wish to use it as a counter in interrupt mode
plz tell me the program... 

shobhitkukreti
User offline. Last seen 16 weeks 5 days ago. Offline
Joined: 04/28/2009
bOt Points: 683
There is a magical thing

There is a magical thing called datasheet, try reading that as well. When i started off with assembly the syntax looked like weird names, TMOD,TCON,SMOD ,you do not encounter them daily, but a little enthusiasm to learn , and i was through. Though i do not use 8051 series microcontrollers , and have started using 'C' compilers , i still peek into the datasheet to know the different register configuration because that is the basic stuff we need to know