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.

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
 
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
AJMP $    ;INFINITE LOOP i.e. END OF PROGRAM
END
Check DPTR in your main code for value = 2KHz (on and off time for getting 1KHz square wave) * 20 = 40000 = 0x9C40.
 
thanks a lot sir..its really helpful

thanks you sir...

you reply has really helped me how to use timer to create delays without using DJNZ command....

really i have no words to thank you..

Hope to get future help on this also.
 
few problems in generating square wave upto 20 seconds

Hi all ,
I have tried to generate a square wave which can produce a Telephone Dial Tone Sound but following are few problems:-

1) Firstly iam using AVS51 simulator , L51 linker and X51 assembler , is there any free downloadable window based software any one can guide me or shareware?

2) For dial tone we have to generate a 400Hz Square Wave,

3) For this i have used 1250 micro-second delay , timer 0 in 16 Bit Mode, and output of square wave is at P2.0.

4) Now when i run this program on simulator , the simulator keeps pn going and going on with the program while i want that after 20 seconds program stops ...any reason why simultor shows this?

5) Next how i can see in the simulator that 400Hz Square is generated upto 20 seconds ...is there any way for this?

6) Can i use the same timer in such a way that after 20 seconds , 400 Hz Square Wave is generated again but with 0.5 seconds ON time and 0.5 Seconds OFF time...i know that you have indicated some hint for doing this in your post but please clear that how to perform this

Like firstly controller bit P1.0 is set when ever telephone set goes off,

At this stage controller sents a 400Hz continues Square Wave upto 20 seconds and

if the telephone set does not go ON Hook then after 20 seconds controller sents 400Hz square wave with 0.5 seconds ON time and 0.5 Off-Time.

Here's the program :-

ORG 00H
JMP MAIN

ORG 000BH
CPL P2.0
INC DPTR
RETI

MAIN:
MOV DPH,#0
MOV DPL,#0
JNB P1.0,$
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
 
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...
 
I think you have misplaced the "NOT" label. Look where it is in my code. :)
 
ya i have seen your codes

the problem is continuining the 400hz tone for 20 seconds and then sending busy tone....
 
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?
 
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...
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top