; PCD3312.ASM - V1.0 - 18/09/1996 ; V2.0 - 12/09/1998 ; ; Générateur sons DTMF PCD3312. ; Protocole de communication I2C: ; Adresse, data. ; Adresse = 48H ou 4Ah. ; Data codé sur 6 bits = 04h à 1Fh + 24h à 3Fh emettent une sonorité. ; 00h à 03h + 20h à 23h aucun son. ; 10h à 1Fh sons DTMF: ; 10h = touche 0 14h = touche 4 18h = touche 8 1Ch = touche C ; 11h = touche 1 15h = touche 5 19h = touche 9 1Dh = touche D ; 12h = touche 2 16h = touche 6 1Ah = touche A 1Eh = touche * ; 13h = touche 3 17h = touche 7 1Bh = touche B 1Fh = touche # ; 00h = silence ;============================================================================== ; Ce programme compose un n° stocké dans une variable sous forme ascii; ;============================================================================== psw equ 0D0h acc equ 0E0h dph equ 083h dpl equ 082h b equ 0F0h p1 equ 090h ;pcon equ 087h ;tcon equ 088h ;tmod equ 089h ;tl1 equ 08Bh ;th1 equ 08Dh ;scon equ 098h ;sbuf equ 099h ;ie equ 0A8h ;============================================================================== bsda equ 097H ;Utilisés par les routines i2c. bscl equ 096H ; trig equ 091H ; ecr_buf equ 1E00h ;Buffer d'écriture I2C. lec_buf equ 1F00h ;Buffer de lecture I2C. acq equ 1DFFh ;Adresse d'acquittement I2C (00h=OK). dtmf equ 04Ah ;Adresse PCD3312 générateur DTMF (A0=1). ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;%%%%%%%%%%%%%%%%%%% Informations supplémentaires %%%%%%%%%%%%%%%%%%%%%%%%%% ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;ecr_buf et lec_buf peuvent pointer sur la même adresse et la taille du buffer ;peut se limiter à 10h octets, seulement 4 octets sont utilisés pour le 3312. ;acq peut se placer dans n'importe quelle adresse et sert à vérifier si le ;dialogue avec le circuit I2c s'est passé sans pb: ;si acq = 00h => Ok , si acq = FFh erreur dialogue avec circuit (ci absent ou occupé) ;Le test de acq se fait aprés la lecture ou l'écriture d'un ci i2c. ;Personnellement, je teste rarement acq sauf pour vérifier la présence d'un ci ;particulier sur le bus. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% org 9000h ;*********************************************************** ; Ce programme teste le montage pcd3312b.sch (PCD3312 + ampli + interface téléphonique) ; en générant un n° de téléphone indiqué en paramètre dans une variable. compos setb p1.5 ;Prend la ligne. mov r4, #02 acall delai ;Delai avant composition n°. mov dptr, #no acall ecr_no ;Compose le n° pointé par 'no'. mov r4, #50 acall delai clr p1.5 ;Raccroche la ligne. ret no db '3611',00h ;Si ce n° est stocké en Ram données, modifier ;movc en movx dans la routine ecr_no. ;============================================================================= ; Routines de gestion générateur DTMF PCD3312: ; ECR_NO : Génération d'un n° de tél. ; TSTDTMF : Emet un son dtmf (pour test). ; ECR_DT : Ecriture sur PCD3312. ; DELAI : Pause de R4 x D000h ; -------------------------------------------------------------------------- ; Génération d'un n° de tél. --------------------------------------------- ecr_no push acc ecr_no1 clr a movc a, @a+dptr ;DPTR pointe le n° en ram programme. jz ecr_no4 ;Si A=0,fin du n°. clr c ;c à 0 pour SUBB sans retenue. subb a, #20h ;Convertit chiffre ascii en code dtmf. lcall ecr_dt ;Compose un chiffre. mov r4, #02 acall delai ;Delai pendant chaque chiffre. inc dptr mov a, #00h lcall ecr_dt ;Génère un silence entre chaque chiffre. mov r4, #01 acall delai ;Delai pendant chaque silence. sjmp ecr_no1 ;Chiffre suivant. ecr_no4 pop acc ret ; -------------------------------------------------------------------------- ; Emet un son DTMF sur le PCD3312 ----------------------------------------- tstdtmf mov a, #10h acall ecr_dt ret ; -------------------------------------------------------------------------- ; Ecriture d'un octet sur PCD3312 ( A=octet à écrire) --------------------- ecr_dt push dph push dpl push acc mov dptr, #ecr_buf mov a, #dtmf ;Adresse PCD3312. movx @dptr, a inc dptr mov a, #01h ;Nbre d'octets à écrire. movx @dptr, a inc dptr pop acc ;Octet à écrire. movx @dptr,a lcall i2c_ecr ;Ecrit sur le bus i2c. pop dpl pop dph ret ; -------------------------------------------------------------------------- ;------- Delai de R4 x D000h. delai push dph push dpl push acc delai1 mov dptr,#0D000h delai2 nop inc dptr mov a,dph orl a,dpl jnz delai2 djnz r4, delai1 pop acc pop dpl pop dph ret ;============================================================================= ; Routines de gestion interface logiciel I2C: ; I2C_ECR : Ecriture sur composant I2C. ; I2C_LEC : Lecture sur composant I2C. ; -------------------------------------------------------------------------- ;------- Ecriture sur composant I2C. i2c_ecr push acc push dph push dpl SETB trig SETB bsda SETB bscl CLR trig ecrit: MOV DPTR,#ecr_buf MOVX A,@DPTR LCALL start JC end INC DPTR MOVX A,@DPTR MOV R1,A trans: INC DPTR MOVX A,@DPTR LCALL mtdat JC end DJNZ R1,trans end: LCALL stop pop dpl pop dph pop acc RET ; ; ; start: CLR bsda NOP NOP NOP NOP CLR bscl mtdat: MOV R2,#08H NOP mstdat: RLC A MOV bsda,C SETB bscl NOP NOP NOP NOP NOP CLR bscl NOP DJNZ R2,mstdat SETB bsda NOP NOP SETB bscl NOP MOV C,bsda NOP NOP CLR bscl RET ; ; ; stop: MOV DPTR,#acq CLR A RLC A MOVX @DPTR,A CLR bsda SETB bscl NOP NOP NOP NOP NOP SETB bsda SETB trig RET ; ; ; -------------------------------------------------------------------------- ;------- Lecture sur composant I2C. i2c_lec push acc push dph push dpl SETB trig SETB bsda SETB bscl CLR trig MOV DPTR,#lec_buf MOVX A,@DPTR MOV R3,A MOV DPTR,#lec_buf+1 MOVX A,@DPTR JZ lect MOV A,R3 LCALL start JC end1 MOV DPTR,#lec_buf+1 MOVX A,@DPTR MOV R1,A trans1: INC DPTR MOVX A,@DPTR LCALL mtdat JC end1 DJNZ R1,trans1 SETB bsda SETB bscl CLR trig NOP NOP NOP NOP lect: MOV A,R3 INC A LCALL start JC end1 INC DPTR MOVX A,@DPTR DEC A INC DPTR JZ suite ;Modifié de la version originale (jc -> jz). MOV R1,A transi: LCALL read LCALL ack MOVX @DPTR,A INC DPTR DJNZ R1,transi suite: LCALL read LCALL nack MOVX @DPTR,A end1: LCALL stop pop dpl pop dph pop acc RET ; ; ; read: MOV R2,#08H CLR A reads: SETB bsda NOP SETB bscl NOP NOP MOV C,bsda NOP CLR bscl RLC A DJNZ R2,reads RET ; ; ; ack: CLR bsda NOP SETB bscl NOP NOP NOP NOP NOP CLR bscl RET ; ; ; nack: SETB bsda SETB bscl NOP NOP NOP NOP NOP CLR bscl RET ;------------------------------------------------------------------------------ end