Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/13/05 00:02
Read: times


 
#84894 - re:
Responding to: ???'s previous message
Well, i try to do this program but it didn´t work. I will paste the code if someone know where is the problem.
If i asign the keyboard to the leds, it works but if i asign to the speaker with the frequencies(only of a one octave, not all)i don´t obtain any sound.


$INCLUDE(REG517.SRC)
teclado equ p1
altavoz equ p4
fila equ 40h
columna equ 41h
digito equ 42h

org 8000h
ljmp principal
org 800bh
ljmp intt0
org 8200h

principal:
lcall DTABLA ;llamar tabla teclado
clr p4.5 ;zumbador apagado
mov tmod,#00000001b ;configuro timer0 en modo 1
mov tl0,#0dfh ;cargo timer a 20ms
mov th0,#0b1h
mov cmsel,#07fh ;Selecionamos comparador del CM7 con el CT("1")
mov cmen,#10000000b ;Habilitamos comparacion ya seleccionada
mov r1,#00h
mov ctcon,#00h ;Entrada del CT con clock=fosc/2
mov dpsel,#01h
mov dptr,#notas ;Apunta a la tabla de notas
setb ien0.7 ;Habilito interrupciones general
setb tr0 ;arranco timer0
setb et0 ;habilitar interrupción timer
setb ien0.5 ;Activo Timer 2 por desbordamiento o interrupción externa

bucle:
ljmp lazo1
sigue:
lcall ponnota
lcall retardo
sjmp bucle

intt0:
mov tl0,#0feh ;comprobación de teclado cada 0,02sg
mov th0,#0ffh
mov teclado,#0fh
mov fila,teclado
mov teclado,#0f0h
mov columna,teclado
mov a,#00h
orl a,fila ;obtengo valor del teclado
orl a,columna
cpl a ;calculo complemento para obtener el valor en la tabla
mov digito,a
reti

lazo1:
mov a,teclado
cjne a,#0fh,lazo2
sjmp lazo1
lazo2:
mov r0,#30h
dec r0
busco:
inc r0
movx a,@r0
cjne a,digito,busco
mov a,r0
mov r2,a
ljmp sigue

retardo:
mov t2con,#00010001b ;timer2 en funcionamiento

espera:
mov a,digito
cjne a,#00h,espera
mov t2con,#00h ;parar timer2
ret


ponnota:mov dpsel,#01h
mov a,r2 ;meto numero nota en registro
movc a,@a+dptr ;apunto a la parte alta de la nota
mov cmh7,a
inc r2 ;incremento r2 para leer siguiente valor
mov a,r2 ;meto r2+1
movc a,@a+dptr ;parte baja nota
mov cml7,a
inc r2
mov a,r2
movc a,@a+dptr
mov ctrelh,a
inc r2
mov a,r2
movc a,@a+dptr
mov ctrell,a
ret


notas: db 03dh,30h,0a6h,61h,0d5h,0bch,0abh,68h,0d8h,14h,0b0h,28h
db 0dah,51h,0b4h,0a3h,0dch,06fh,0b8h,0deh,0deh,6eh,0bch,0dch
db 0e0h,50h,0c0h,0a0h,0e2h,17h,0c4h,2fh,0e3h,0c5h,0c7h,8ah,0e5h,5bh,0cah,0b6h
db 0e6h,0d9h,0cdh,0aeh,0e8h,43h,0d0h,86h

DTABLA:
mov r0,#30h
mov @r0,#10001000b ;DO
inc r0
mov @r0,#10000100b ;D0#
inc r0
mov @r0,#10000010b ;RE
inc r0
mov @r0,#10000001b ;RE#
inc r0
mov @r0,#01001000b ;MI
inc r0
mov @r0,#01000100b ;FA
inc r0
mov @r0,#01000010b ;FA#
inc r0
mov @r0,#01000001b ;SOL
inc r0
mov @r0,#00101000b ;SOL#
inc r0
mov @r0,#00100100b ;LA
inc r0
mov @r0,#00100010b ;LA#
inc r0
mov @r0,#00100001b ;SI
;mov a,#12d
ret
end


Thanks


List of 23 messages in thread
TopicAuthorDate
How to make a piano            01/01/70 00:00      
   Happy to help but...            01/01/70 00:00      
   Piano, violin, trumpet ...            01/01/70 00:00      
      Not a Piano            01/01/70 00:00      
         And not a Violin            01/01/70 00:00      
   re:            01/01/70 00:00      
      frequencies            01/01/70 00:00      
         you could also            01/01/70 00:00      
         getting 41.2 Hz out using T2 AutoReload            01/01/70 00:00      
            select proper xtal            01/01/70 00:00      
      Try higher pitches            01/01/70 00:00      
   well..            01/01/70 00:00      
      8 octaves with 16 keys???            01/01/70 00:00      
      What?            01/01/70 00:00      
   re:            01/01/70 00:00      
      Enough power?            01/01/70 00:00      
         to Joseph            01/01/70 00:00      
   Software reformated. No changes.            01/01/70 00:00      
      How to post code            01/01/70 00:00      
      just the obvious errors            01/01/70 00:00      
   iguana labs sound tutorial            01/01/70 00:00      
   debugging            01/01/70 00:00      
   Be more descriptive!!            01/01/70 00:00      

Back to Subject List