Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HOW to gernerate frequecy from 1 Hz to 200 Hz using timer as interrupt in 89S52

Status
Not open for further replies.

bondhwal

New Member
HI

I want to write routine like this
;==================================

; Crystal Frequency = 24MHz
;
; mode setting for timer
MOV TMOD,#0H ; mode 0, 13-bit timer
MOV SAV_TH1,#254;
MOV SAV_TL1,#27
MOV TL1,SAV_TL1
MOV TH1,SAV_TH1


TIMER1_ISR:
PUSH ACC ; 1uS
PUSH PSW ; 1uS
NOP ;.5uS ;
CLR TR1 ; .5uS ;timer interrupt
MOV TL1,SAV_TL1 ;1uS
MOV TH1,SAV_TH1 ;1uS
NOP ;.5uS
SETB TR1 ; .5uS
MOV PSW,#018H ;1uS
JB OUTPUT,CLR_OUTPUT ;1uS
CJNE R7,#00,RET_T11 ;1uS
MOV R7,PWM_MULTP2 ;1uS
SETB OUTPUT ;.5uS
NOP ;.5uS
JMP RET_T1 ;1uS
RET_T11: NOP ;.5uS
DEC R7 ;.5uS
RET_T1:
POP PSW ;1 uS
POP ACC ;1 uS
RETI ;
CLR_OUTPUT:
CJNE R7,#00,RET_T11 ;1uS
DJNZ R6,RET_T1 ;1uS
MOV R6,#2 ;1uS
DJNZ R5,RET_T1 ;1uS
MOV R5,#235 ;1uS
MOV R7,PWM_MULTP1 ;1uS
NOP ;.5uS
CLR OUTPUT ;.5uS
JMP RET_T1 ;1uS
================================

I need help in making a formula to generate frequency from 1Hz to 200 Hz with above asm code.
Pls reply.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top