| ??? 03/24/03 05:10 Read: times |
#42150 - Produce a sound in moving coil speaker |
I need to produce a sound but not a simple tone in 8051 with moving coil speaker.
Hardware: connecting with 270ohm, 10uF, and P1.7 in 8051 seriously with moving coil speaker. Software: it can't use timer 2 auto mode because it is 16 bit thing... therefore i've used timer 0 mode 1 to try to produce a sound. ;This program demonstrates using the on chip programmable timer approach to ;generate the ambulance siren on the speaker. $TITLE(Sound Effect of Laser Gun - Timer Approach) $DATE(28-Dec-00) $LIST $MOD51 ;Symbol and Data Section TEMP_LO DATA 30h ;Temporary location for holding the initial TEMP_HI DATA 31h ;value - low and high bytes respectively LOOP_COUNTER DATA 32h ;Loop counter for laser gun ORG 0000h LASER_GUN: MOV TMOD,#01h GUN_1: MOV LOOP_COUNTER,#60 ;Initialize the LOOP_COUNTER MOV TEMP_LO,#55h ;Loading the default initialize MOV TEMP_HI,#0FFh ;value for timer 0 of freq 2700 Hz GUN_2: MOV TL0,TEMP_LO ;Get low and high byte initial value MOV TH0,TEMP_HI ;to timer register TL0 and TH0 SETB TR0 ;Start timer 0 MOV R5,#3 ;Set delay for 6 ms ACALL DELAY ACALL UPDATE DJNZ LOOP_COUNTER,GUN_2 CLR TR0 ;Stop timer 0 MOV R5,#250 ;Set delay for 0.5 sec ACALL DELAY ;Total delay = 1 sec SJMP GUN_1 HERE: JBC TF0, GUN_2 SJMP HERE ;Update the initial value to be loaded to the timer 0 UPDATE: CLR TR0 ;Stop timer 0 CLR C MOV A,TEMP_LO SUBB A,#1 MOV TEMP_LO,A MOV A,TEMP_HI SUBB A,#00 MOV TEMP_HI,A RET ;Time delay for [(12 + 12*5 + 24*200*5 + 24*5 + 24)*R5 + 24] clock cycles ;i.e. approx. R5*0.002 sec DELAY: MOV R6,#5 ;12*R5 clock cycles DEL_1: MOV R7,#200 ;12*5*R5 clock cycles DEL_2: DJNZ R7,DEL_2 ;24*200*5*R5 clock cycles DJNZ R6,DEL_1 ;24*5*R5 clock cycles DJNZ R5,DELAY ;24*R5 clock cycles RET ;24 clock cycle END I don't know why It still can't produce any sound out! PLease help! or can somebody give me other ways to write the programme? Thank you! P.S. i think the hardware is not the problem but the problem is from the program. |
| Topic | Author | Date |
| Produce a sound in moving coil speaker | 01/01/70 00:00 | |
| RE: Produce a sound in moving coil speaker | 01/01/70 00:00 | |
| RE: Produce a sound in moving coil speak | 01/01/70 00:00 | |
| RE: Produce a sound in moving coil speaker | 01/01/70 00:00 | |
| RE: Produce a sound in moving coil speaker | 01/01/70 00:00 | |
RE: Produce a sound in moving coil speaker | 01/01/70 00:00 |



