Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/03/02 09:15
Read: times


 
#20331 - RE: Counters with the 8051
hai Daire,
just go through doucument mention in the below link!
http://www.semiconductors.philips.com/acrobat/v...ARCH_1.pdf

Page 6 to 8 expalins the timer operations!

I have helped a group of students, who were doing a project on ultrasonic distance meter!

try the following code:

START1:
.ORG 0000H
LJMP 0050H ;start code execution from here
INT1:
.ORG 0013H
RETI ;INTERRUPT SERVICE SUBROUTINE...
TIM_INT0:
.ORG 000BH
LJMP 1000H ;TIMER Interrupt zero
TIM_INT1:
.ORG 001BH
RETI ;TIMER Interrupt one
TIM_INT2:
.ORG 002BH
RETI ;TIMER Interrupt TWO
CODE_BEGIN:
.ORG 0050H

INITIAL: MOV IE,#00H ;Disable interruptS

;CLEAR INTERNAL RAM

MOV R0,#FFH ;CLEAR INTERNAL RAM
MOV A,#00H
CLEAR_RAM: MOV @R0,A
DJNZ R0,CLEAR_RAM

;TIMER0 INITIALISATION
CLR TR0
CLR TF0
MOV TH0,#VALUE1
MOV TL0,#VALUE2
MOV TMOD,#11H ;TIMER0 MODE 1
SETB P1.0 ; LET ME ASSUME U R USING P1.0 FOR ;GENERATING SQUARE WAVE
MOV COUNT1,#00H
MOV COUNT2,#00H
MOV IE,#82H
SETB TR0 ;SART TIMER
MAIN:
;(YOUR ANALOG INPUT CHECK HERE,I AM JUST ASSUMING IT TO BE BIT ADDRESSABLE)
CLR C
MOV C,PORT_PIN ;USED APPROPRIATE LOGIC TO CHECK UR ANALOG PIN
JC RXED
JMP MAIN
RXED:
;HOW MANY TIMES UR COUNTER HAS RUN WILL BE STORED IN COUNT1 AND COUNT2 REG)

CLR TR0
CLR TF0
JMP UR_ROUTINE ;FROM HERE U SHALL JMP TO UR ROUTINE
;TIMER0

.ORG 1000H
CLR TR0
CLR TF0
CPL P1.0 ; TOGGLEING TO GET SQUARE WAVE
INC COUNT1
JNC OUT1
CLR C
INC COUNT2 ;16 BIT COUNTING IS USED U SHALL MODIFY AS U REQUIRE
OUT1:
MOV TH0,#VALUE1
MOV TL0,#VALUE2
SETB TR0
RETI

IF U R NOT GETTING THE PROGRAM IN RIGHT FORMAT ,THEN COPY IT INTO NOTEPAD!

I am not sure whether this is what u want but ITS WORKING IN MY EMULATOR!
By the way which part no. u r using????

All the best!
rgds,
dana

List of 8 messages in thread
TopicAuthorDate
Counters with the 8051            01/01/70 00:00      
RE: Counters with the 8051            01/01/70 00:00      
RE: Counters with the 8051            01/01/70 00:00      
SMALL CORRECTION            01/01/70 00:00      
SMALL CORRECTION ON ISS            01/01/70 00:00      
RE: SMALL CORRECTION ON ISS            01/01/70 00:00      
RE: Counters with the 8051            01/01/70 00:00      
RE: Counters with the 8051            01/01/70 00:00      

Back to Subject List