# some asembly coding help needed 1000hz square wave ?

Status
Not open for further replies.

#### waqar

##### New Member
Objective is when ever Telephone Set goes off hook , controller detects off hook and sents a Dial Tone to the telephone set for 20 Seconds and after 20 seconds program END.

 Using 12 MHz Crystal.
 Firstly the Program do nothing untill a logical high signal comes at P1.0.
 When a Logical high Signal somes at P1.0,
 Timer 0 interrupt comes in act
 1000 Hz square wave is produced at P2.0.
 Now how I can make controller to sent this upto 20 seconds and,
 After that sents a Busy TONE type of Sound by generating the same square wave but with 0.1 second ON and 0.1 Second OFF.

ORG 00H
LJMP MAIN

ORG 000BH
CPL P2.0
RETI

MAIN:
JNB P1.0,$JMP DIAL TONE DIAL TONE: MOV TMOD,#20H MOV TH0,,#-50 SETB TR0 MOV IE,#82H Upto 20 seconds DIAL TONE and after that BUSY TONE keeps on going. END #### kinjalgp ##### Active Member You need to count the time duration in interrupt. Since you are using timer to complement P2.0 at every interrupt, you can also increment pair of 8-bit registers (for 16-bit counting or more if you need)in your ISR. Now check this count for desired value from your main program and end it when you reach the desired value. I am using DPTR (16-bit) for following example. Code: ORG 00H LJMP MAIN ORG 000BH CPL P2.0 INC DPTR RETI MAIN: MOV DPH,#0 MOV DPL,#0 JNB P1.0,$
JMP DIAL TONE

DIAL TONE:
MOV TMOD,#20H
MOV TH0,,#-50
SETB TR0
MOV IE,#82H
NOT_EQ:
MOV A,DPH
CJNE A,#9Ch,NOT_EQ
MOV A,DPL
CJNE A,#40h,NOT_EQ
CLR TR0        ;STOP TIMER 0 AND THEN END
JMP DIAL

DIAL:
MOV TMOD,#01B
CLR TR0
MOV TH0,#FBH
MOV TL0,#1EH
SETB TR0
SETB ET0
SETB EA
MOV A,DPH
CJNE A,#C8H,NOT
MOV A,DPL
CJNE A,#50H,NOT

NOT:
SJMP \$
END

#### waqar

##### New Member
please guide me how to do this

i have tried many times but unable to do this...please check my above mentioned codes and provide me some suggestion howt o perform this...

#### kinjalgp

##### Active Member
I think you have misplaced the "NOT" label. Look where it is in my code.

#### waqar

##### New Member
ya i have seen your codes

the problem is continuining the 400hz tone for 20 seconds and then sending busy tone....

#### kinjalgp

##### Active Member
Thats what I am saying. Look at the "NOT" label you have placed at. It should be at place where my "NOT_EQ" label is. By the way, where is the code for busy tone?

#### waqar

##### New Member
ok got it

ok..its clear now....

so now if i place a 8 ohms speaker and connect it at p2.0 i will hear these sounds...rights.

can i generate these sounds using KA1458 dual operation amplifier...

#### kinjalgp

##### Active Member
Yes you can do it.

#### waqar

##### New Member
how i can use KA1458 some guidance needed

Suppose if i have 8 ohms speaker connected to p2.0

how i can make use of KA1458 to sents dial tone , busy tone and ring tone to this speaker ....

let say when i give supply to the controller..

dial tone starts to occur on the speaker for 20 seconds....

after that busy tone starts to appear untill power is disconnected...

i have seen its datasheet but did not understand any thing how to use it for tone generation..

Status
Not open for further replies.