| ??? 04/03/03 01:21 Read: times |
#42796 - using only one timer for 400Hz & 20sec Responding to: ???'s previous message |
1) as you said:-
"almost forgot:what kind of assembler are you using that permit this: CJNE A,#50H,NOT ? ,you can't use a reserved word as a label! " Answer:- Iam using X51 and ran the program many times but it did not show any error so is the assembler working ok or there is some problem. 2) as you said:- "by the way...look your code... I didn't do the math, but I think that you have done wrong the square wave timing and the 20s timer. and assembly code without comments should be punished with a scourge... " Answer:- you are right i will use comments when ever i will post here again....next the maths for 400Hz and 20 seconds... Time = 1/400Hz = 0.0025 seconds. x 1000000 = 2500micro-seconds. = 2500/2 1250 times ON and 1250 Times OFF should create 400Hz Square Wave. using timer 0 in 16 bit Mode. 65536 (Max. value 16 bit timer can over flow) - 1250 = 64286 converting 64286 into hex = FB1E so FB is the value to be loaded in TH0 and 1E is the value for TL0. each time timer over flows P2.0 is complemented. Now the above process will generate 400Hz Sqaure Wave..rite ? Next is generating the same sound for 20 seconds :- For that i have used DPTR increment command using the following maths:- timer over flow at = 1250 DPH (inner Loop) = 200 times DPL (outer loop) = 80 times. 20 seconds time = {1250*(200*80) }/ 1000000 = 20 seconds. please indicate if there is any problem in above maths ? Now i want to make the program without using the second timer i mean that 400Hz tone upto 20 seconds using only one timer. program on simulator AVS51 still show that only 7.89 seconds has passed i think there is something i have to do with using DPH and DPL in a proper way which at this moment iam not understanding.. ORG 00H LJMP MAIN ORG 000BH ;timer 0 vector address JMP TOISR MAIN: MOV TMOD,#01B ;timer 0 in 16 bit mode MOV DPH,#0 ;inner loop MOV DPL,#0 ;outer loop JNB P1.0,$ ;program waiting to detect telephone off hook SETB TF0 ;forcing timer 0 interrupt SETB EA ;enable global interrupt SETB ET0 ;enable timer 0 interrupt TOISR: CLR TR0 MOV TH0,#FBH ;count 400hz MOV TL0,#1EH CPL P2.0 ;DIAL tone Sqaure Wave SETB TR0 MOV A,DPH CJNE A,#C8H,DO_NOTHING ;inner loop will run 200 times MOV A,DPL CJNE A,#50H,DO_NOTHING ;out loop will run 80 times DO_NOTHING: SJMP $ END |
| Topic | Author | Date |
| 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| iam not asking any one to design | 01/01/70 00:00 | |
| RE: iam not asking any one to design | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| RE: 400hz square wave upto 20 seconds | 01/01/70 00:00 | |
| using only one timer for 400Hz & 20sec | 01/01/70 00:00 | |
RE: using only one timer for 400Hz & 20sec | 01/01/70 00:00 |



