intel's mcs-51 family of microcontrollers and its ... · music synthesizer interface 3 the...
TRANSCRIPT
![Page 1: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/1.jpg)
MUSIC SYNTHESIZER INTERFACE
1
CONTENTS
PAGE NO
1.0 Introduction 2
2.0 Description of the Circuit 2
3.0 Installation 2
4.0 Demonstration Examples 3
4.1 Demonstration Program for MPS 85-3 Trainer 4
4.2 Demonstration Program for ESA 85-2 Trainer 6
4.3 Demonstration Program for ESA-31 Trainer 8
4.4 Demonstration Program for ESA-68K Trainer 10
4.5 Demonstration Program for ESA 196 Trainer 13
4.6 Demonstration Program for ESA 86/88-2 Trainer 14
4.7 Demonstration Program for ESA-51 Trainer 17
4.8 Demonstration Program for ESA 86/88-3 Trainer 19
4.9 Demonstration Program for ESA 51E Trainer 21
Appendix A : Component Layout Diagram
Appendix B : Schematic Diagram
![Page 2: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/2.jpg)
MUSIC SYNTHESIZER INTERFACE
2
MUSIC SYNTHESIZER INTERFACE
1.0 INTRODUCTION
The music synthesizer interface makes MPS-85 a simple electronic organ. It makes use of the
programmable peripheral interface chip 8255 to generate tones. The sample program generates a
tone for each key pressed. Only the hex keys are used for generating tones. Each key is
programmed to give a different frequency of output.
2.0 DESCRIPTION OF THE CIRCUIT
The interface consists of a transistor, a LED & a speaker. The connections are shown in the
schematic diagram. The transistor acts as an amplifier and drives the 8ohm loud speaker. The LED
is provided to indicate that a tone is being generated. In the sample program the keys are
programmed through 8279 in the encoded scan sensor matrix mode so that when a key is pressed,
bit PC7 of 8255 will send out pulses to generate a tone corresponding to the key pressed. This tone
will not terminate until the key is released. Key 0 - key F are mapped to generate a tone as given
below. If other keys are pressed there will not be any response from the speaker.
Key Mapping To Tone
KEY 0 1 2 3 4 5 6 7 8 9 A B C D E F
OCTAVE B C D E F G A B C D E F G A B C
An octave ranges from a C to a B. It is divided into 5 full-tones and 2 half-tones, which equal to
12 half-tones, as follows:
C #C D #D E F #F G #G A #A B
The next octave is just twice the frequency of the current one, and there is a logarithmic
relationship between each half-tone. So that the frequency of each half-tone can be calculated by
multiplying the last one by 2 log (1/12), which is approximately equal to 1.059.
3.0 INSTALLATION
The interface is housed in a plastic enclosure which has a locking mechanism. To open the cover,
push in the locking mechanism with a finger and lift the cover to open.
![Page 3: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/3.jpg)
MUSIC SYNTHESIZER INTERFACE
3
The interface module has a 26-pin connector at one edge of the card. This is used for connecting the
interface to the trainer with a flat cable connector set. The +5V DC power required by this
interface is drawn from the trainer via the flat cable connector set.
Table 3-1 shows the connector on various trainers to which this interface can be connected. Some
trainers have two connectors and either may be used for connecting this interface. The
demonstration programs presented in this manual assumes that the interface is connected to
connectors shown in column A. If the connector shown in column B is used, then user has to
change the port addresses appropriately. User may refer to the component layout diagrams of
respective ESA trainers to locate the connectors mentioned here.
TABLE-3.1
MICROPROCESSOR
TRAINER
A B
MPS85-3 J2 J1
ESA85-2 J2 J1
ESA-80 J2 J1
ESA-65 P4
ESA-68K P3 P4
ESA 68K-2 J2 J1
ESA 68-2 J1 J6
ESA 196 J1 J2
ESA-31 J2 J1
ESA-51 J10 J7
ESA-51E J5 J3
ESA-86/88-2 J4 J5
ESA-86/88-3 J8 J9
ESA-86/88E J4 J6
4.0 DEMONSTRATION EXAMPLES
After executing the sample program, it generates a tone for each key pressed. Only the hex keys are
used for generating tones. Each key is programmed to give a different frequency of output.
![Page 4: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/4.jpg)
MUSIC SYNTHESIZER INTERFACE
4
4.1 DEMONSTRATION PROGRAM FOR MPS 85-3 TRAINER
; Assume the interface is connected over J2 of the trainer
; The trainer can be in KEYBOARD MODE or SERIAL MODE.
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
8800 3E 04 START: MVI A,04H ;Configure 8279
8802 D3 31 OUT 31H Encoded scan sensor
matrix mode.
8804 3E 30 MVI A,30H ;Program clock of 8279
8806 D3 31 OUT 31H
8808 3E C1 NXTKEY: MVI A,0C1H ;Clear 8279 Buffer
880A D3 31 OUT 31H
880C 3E E0 RDSTAT: MVI A,0E0H
880E D3 31 OUT 31H
8810 DB 31 IN 31H ;Get status word from
;accumulator. If key
;pressed bit 6 is set.
8812 E6 40 ANI 40H
8814 FE 40 CPI 40H ;Check if key is pressed
8816 C2 0C 88 JNZ RDSTAT ;No, Read status word
8819 0E 00 MVI C,00H ;from accumulator.
881B 3E 50 MVI A,50H ;configure 8279 in
881D D3 31 OUT 31H ;Auto increment mode.
881F DB 30 IN 30H
8821 B7 ORA A
8822 C2 2C 88 JNZ GETKEY ;check any key is
;pressed.
8825 0C INR C
8826 DB 30 IN 30H
8828 B7 ORA A ;If no key is pressed
8829 CA 00 88 JZ START ;wait till a key is
;pressed.
882C 06 00 GETKEY: MVI B,00H
882E 37 STC
882F 3F CMC
8830 0F SHRAGN: RRC
8831 DA3888 JC KEYCODE
8834 04 INR B
8835 C3 30 88 JMP SHRAGN
8838 79 KEYCOD: MOV A,C ;Get key code to
;accumulator
8839 E61F ANI 1FH
883B 07 RLC ;Shift left three times
![Page 5: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/5.jpg)
MUSIC SYNTHESIZER INTERFACE
5
883C 07 RLC
883D 07 RLC
883E 80 ADD B
883F 21 6D 88 LXI H,FREQTB ;HL is pointing to
;Base address of FREQTB
8842 85 ADD L ;Add key code to `L'.
8843 6F MOV L,A ;HL will have the
;frequency for the key
;pressed.
8844 3E 80 MVI A,80H ;Initialise 8255 to
;mode 0, port C as O/P.
8846 D3 43 OUT 43H
8848 0E 4F MVI C,4FH ;Bit 7 of C port is
;made high.
884A 3E 00 NXTPLS: MVI A,00 ;Pulse is output on
;PC7
884C D3 42 OUT 42H
884E 46 MOV B,M ;Get frequency pointed
;by HL in register B.
884F 1B NXTPRD: DCX D ;Dummy instruction
8850 1B DCX D ;for Delay.
8851 1B DCX D
8852 1B DCX D
8853 1B DCX D
8854 05 DCR B
8855 C2 4F 88 JNZ NXTPRD ;Frequency of pulses to
;be output on PC7.
8858 3E FF MVI A,0FFH ;Make PC7 of port C
;high.
885A D3 42 OUT 42H ;output pulse on PC7
885C 46 MOV B,M ;Get frequency pointed
;by HL to register B.
885D 1B NXT: DCX D ;Dummy instruction to
885E 1B DCX D ;introduce delay.
885F 1B DCX D
8860 1B DCX D
8861 1B DCX D
8862 05 DCR B
8863 C2 5D 88 JNZ NXT
8866 0D DCR C
8867 C2 4A 88 JNZ NXTPLS
886A C3 0C 88 JMP RDSTAT ;Check if key is
;still pressed.
886D B7 A8 96 FREQTB: DFB 0B7H,0A8H,96H,85H,7EH,70H,64H,
8870 85 7E 70 59H,54H,4AH,42H,3EH,37H,31H,2CH,29H
![Page 6: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/6.jpg)
MUSIC SYNTHESIZER INTERFACE
6
8873 64 59 54
8876 4A 42 3E
8879 37 31 2C
887C 29
4.2 DEMONSTRATION PROGRAM FOR ESA 85-2 TRAINER
; Assume the interface is connected over J2 of the trainer.
; The trainer can be in KEYBOARD MODE or SERIAL MODE.
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
8000 3E 04 START: MVI A,04H ;Configure 8279
8002 D3 31 OUT 31H ;Encoded scan sensor
;matrix mode.
8004 3E 30 MVI A,30H ;Program clock of 8279
8006 D3 31 OUT 31H
8008 3E C1 NXTKEY: MVI A,0C1H ;Clear 8279 Buffer
800A D3 31 OUT 31H
800C 3E E0 RDSTAT: MVI A,0E0H
800E D3 31 OUT 31H
8010 DB 31 IN 31H ;Get status word from
;accumulator.
;If key pressed bit 6 is
;set.
8012 E6 40 ANI 40H
8014 FE 40 CPI 40H ;Check if key is pressed
8016 C2 0C 80 JNZ RDSTAT ;No Read status word
8019 0E 00 MVI C,00H ;from accumulator.
801B 3E 50 MVI A,50H ;configure 8279 in
801D D3 31 OUT 31H ;Auto increment mode.
801F DB 30 IN 30H
8021 B7 ORA A
8022 C2 2C 80 JNZ GETKEY ;check any key is
;pressed.
8025 0C INR C
8026 DB 30 IN 30H
8028 B7 ORA A ;If no key is pressed
8029 CA 00 80 JZ START ;wait till a key is
;pressed.
802C 06 00 GETKEY: MVI B,00H
802E 37 STC
802F 3F CMC
8030 0F SHRAGN: RRC
![Page 7: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/7.jpg)
MUSIC SYNTHESIZER INTERFACE
7
8031 DA3880 JC KEYCODE
8034 04 INR B
8035 C3 30 80 JMP SHRAGN
8038 79 KEYCOD: MOV A,C ;Get key code to
;accumulator
8039 E61F ANI 1FH
803B 07 RLC ;Shift left three times
803C 07 RLC
803D 07 RLC
803E 80 ADD B
803F 21 6D 80 LXI H,FREQTB ;HL is pointing to Base
;address of FREQTB
8042 85 ADD L ;Add key code to `L'.
8043 6F MOV L,A ;HL will have the
;frequency for the key
;pressed.
8044 3E 80 MVI A,80H ;Initialise 8255 to
;mode 0, port C as
;output port.
8046 D3 43 OUT 43H
8048 0E 4F MVI C,4FH ;Bit 7 of C port is
;made high
804A 3E 00 NXTPLS: MVI A,00 ;Pulse is output on PC7
804C D3 42 OUT 42H
804E 46 MOV B,M ;Get frequency pointed
;by HL in register B.
804F 1B NXTPRD: DCX D ;Dummy instruction for
8050 1B DCX D ;Delay.
8051 1B DCX D
8052 1B DCX D
8053 1B DCX D
8054 05 DCR B
8055 C2 4F 80 JNZ NXTPRD ;Frequency of pulses to
;be output on PC7.
8058 3E FF MVI A,0FFH ;Make PC7 of port C
;high.
805A D3 42 OUT 42H ;output pulse on PC7
805C 46 MOV B,M ;Get frequency pointed
;by HL to register B.
805D 1B NXT: DCX D ;Dummy instruction to
805E 1B DCX D ;introduce delay.
805F 1B DCX D
8060 1B DCX D
8061 1B DCX D
8062 05 DCR B
![Page 8: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/8.jpg)
MUSIC SYNTHESIZER INTERFACE
8
8063 C2 5D 80 JNZ NXT
8066 0D DCR C
8067 C2 4A 80 JNZ NXTPLS
806A C3 0C 80 JMP RDSTAT ;Check if key is
; still pressed.
806D B7 A8 96 FREQTB: DB 0B7H,0A8H,96H,85H,7EH,70H,64H,
8070 85 7E 70 59H,54H,4AH,42H,3EH,37H,31H,2CH,29H
8073 64 59 54
8076 4A 42 3E
8079 37 31 2C
807C 29
4.3 DEMONSTRATION PROGRAM FOR ESA-31 TRAINER
; Assume the interface is connected over J2 of the trainer.
; The trainer can be in KEYBOARD MODE or SERIAL MODE.
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
8000 75 A0 EC START: MOV P2,#0ECH ;Configure 8279
8003 74 04 MOV A,#04H ;encoded scan
8005 78 01 MOV R0,#01H ;sensor matrix.
8007 F2 MOVX @R0,A
8008 74 30 MOV A,#030H ;Program clock.
800A F2 MOVX @R0,A
800B 74 C1 MOV A,#0C1H ;Clear 8279.
800D F2 MOVX @R0,A
800E 75 A0 EC RDSTAT: MOV P2,#0ECH
8011 78 01 MOV R0,#01H
8013 74 E0 MOV A,#0E0H
8015 F2 MOVX @R0,A
8016 E2 MOVX A,@R0 ;Get status word
8017 54 40 ANL A,#40H ;from accumulator.
8019 B4 40 F2 CJNE A,#40H,RDSTAT ;If key pressed
801C 7B 00 MOV R3,#00 ;bit 6 is pressed.
801E 74 50 MOV A,#50H ;Configure 8279
8020 F2 MOVX @R0,A ;in Auto increment
;mode.
8021 78 00 MOV R0,#00
8023 E2 MOVX A,@R0
8024 70 05 JNZ GETKEY ;Check any key is
8026 0B INC R3 ;pressed.
8027 E2 MOVX A,@R0 ;If no key is
8028 48 ORL A,R0 ;pressed,wait till
![Page 9: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/9.jpg)
MUSIC SYNTHESIZER INTERFACE
9
8029 60 D5 JZ START ;a key is pressed.
802B 7C 00 GETKEY: MOV R4,#00
802D D3 SETB C
802E B3 CPL C
802F 13 SHRAGN: RRC A
8030 40 03 JC KEYCODE
8032 0C INC R4
8033 80 FA SJMP SHRAGN
8035 EB KEYCODE: MOV A,R3 ;Get keycode to
8036 54 1F ANL A,#01FH ;accumulator.
8038 23 RL A ;Shift left
8039 23 RL A ;three times.
803A 23 RL A
803B 2C ADD A,R4
803C 90 80 6C MOV DPTR,#FREQTB ;Add keycode to
803F 25 82 ADD A,DPL ;data pointer.
8041 F5 82 MOV DPL,A ;DPL will have the
;frequency for
;key pressed.
8043 7B 4F MOV R3,#04FH ;Bit 7 of Port C
;is made high.
8045 74 00 NXTPLS: MOV A,#00 ;Pulse is O/P
8047 F5 90 MOV P1,A ;on PC7.
8049 E4 CLR A
804A 93 MOVC A,@A+DPTR ;Get frequency
804B FC MOV R4,A ;pointed by
804C 1D NXTPRD: DEC R5 ;DPTR.
804D 1D DEC R5
804E 1D DEC R5
804F 1D DEC R5
8050 1D DEC R5
8051 1C DEC R4
8052 BC 00 F7 CJNE R4,#00,NXTPRD
8055 74 FF MOV A,#0FFH
8057 F5 90 MOV P1,A
8059 E4 CLR A
805A 93 MOVC A,@A+DPTR
805B FC MOV R4,A
805C 1D NXT: DEC R5
805D 1D DEC R5
805E 1D DEC R5
805F 1D DEC R5
8060 1D DEC R5
8061 1D DEC R5
8062 1C DEC R4
![Page 10: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/10.jpg)
MUSIC SYNTHESIZER INTERFACE
10
8063 BC 00 F6 CJNE R4,#00,NXT
8066 1B DEC R3
8067 BB 00 DB CJNE R3,#00,NXTPLS
806A 80 A2 SJMP RDSTAT
806C B7 A8 96 FREQTB: DB 0B7H,0A8H,96H
806F 85 7E 70 DB 85H,7EH,70H
8072 64 59 54 DB 64H,59H,54H
8075 4A 42 3E DB 4AH,42H,3EH
8078 37 31 2C 29 DB 37H,31H,2CH,29H
4.4 DEMONSTRATION PROGRAM FOR ESA-68K TRAINER
; Assume the interface is connected over P3 of the trainer.
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
040600 13FC 0080 0008 MOVE.B #$80,CNTPRT ;Configure all
0306 ;ports of 8255
;as O/P ports.
040608 4EB8 04E0 SCAN: JSR GETCHR ;Scan keyboard
;using monitor
;routine 'GET
;CHAR'.
;(D1)=Keycode.
04060C 267C 0004 0682 MOVE.L #STRING,A3 ;Point to the
;table of hex
;keys.
040612 247C 0004 0672 MOVE.L #FRQTBL,A2 ;Point to table
;of frequencies.
040618 287C 0004 06A2 MOVE.L #DURTN,A4 ;Point to table
;of durations of
;tones.
04061E 363C 0000 MOVE #00,D3 ;Counter for
;number of keys
;scanned.
040622 3C3C 0000 MOVE #00,D6 ;Index for table
;of hex keys.
040626 101B FINDKY:MOVE.B (A3)+,D0 ;Check if the
;key pressed is
;a hex key.
;Uppercase and
;lower case hex
;characters
![Page 11: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/11.jpg)
MUSIC SYNTHESIZER INTERFACE
11
;should be
;considered as
;the same.
040628 B200 CMP.B D0,D1 ;So,compare with
;a uppercase hex
;key.
04062A 6700 0016 BEQ GENTON ;If it matches
;generate
;corresponding
;tone.
04062E 101B MOVE.B (A3)+,D0 ;Else,compare
;with
;corresponding
040630 B200 CMP.B D0,D1 ;lowercase
;character.
040632 6700 000E BEQ GENTON ;If it matches
;generate
;corresponding
;tone.
040636 5446 ADDQ #02,D6 ;Else increment
;key counter and
040638 5243 ADDQ #01,D3 ;point to next
;hex key.
04063A 0C43 0010 CMPI #$10,D3 ;Compared with
;all hex keys ?
04063E 66E6 BNE FINDKY ;No,compare with
;next key.
040640 60C6 BRA SCAN ;Yes,scan
;keyboard again.
040642 D4C3 GENTON:ADDA D3,A2 ;(A2)=Frequency
;code
;corresponding to
;the key pressed.
040644 D8C6 ADDA D6,A4 ;(A4)=Code for
;duration of tone
;generation for
;the key.
040646 3A14 MOVE (A4),D5
040648 1812 NEXT: MOVE.B (A2),D4
04064A 13FC 0000 0008 MOVE.B #00,PORTC ;(PC7)=0.
0304
040652 4E71 DELAY1:NOP ;Duration of
;low level
040654 4E71 NOP ;of square wave
040656 5304 SUBQ.B #01,D4 ;generating the
![Page 12: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/12.jpg)
MUSIC SYNTHESIZER INTERFACE
12
;tone.
040658 66F8 BNE DELAY1
04065A 1812 MOVE.B (A2),D4
04065C 13FC 0080 0008 MOVE.B #$80,PORTC ;(PC7)=1
0304
040664 4E71 DELAY2:NOP ;Duration of high
040666 4E71 NOP ;level of the
040668 5304 SUBQ.B #01,D4 ;square wave.
04066A 66F8 BNE DELAY2
04066C 5345 SUBQ #01,D5 ;Required number
;of pulses sent ?
04066E 66D8 BNE NEXT ;No,send one more
;pulse.
040670 6096 BRA SCAN ;Check for any
;more key
;depressions.
040672 B7 A8 96 85 FRQTBL:.BYTE $B7,$A8,$96,$85 ;Table of
040676 7E 70 64 59 .BYTE $7E,$70,$64,$59 ;frequency
04067A 54 4A 42 3E .BYTE $54,$4A,$42,$3E ;codes for
04067E 37 31 2C 29 .BYTE $37,$31,$2C,$29 ;the hex
;keys '0' to
;'F' in the
;same order.
040682 30 30 31 31 32 STRING:.BYTE '0011223344556677'
;Table of hex
040687 32 33 33 34 34 ;incorporating
04068C 35 35 36 36 37 ;both upper
040691 37 ;and lowercase
040692 38 38 39 39 41 .BYTE '8899AaBbCcDdEeFf' ;keys.
040697 61 42 62 43 63
04069C 44 64 45 65 46
0406A1 66
0406A2 0050 0057 DURTN: .WORD $50,$57,$61,$6E
;Table of codes
0406A6 0061 006E ;corresponding
0406AA 0074 0082 .WORD $74,$82,$92,$A4 ;to the
0406AE 0092 00A4 ;durations
0406B2 00AE 00C5 .WORD $AE,$C5,$DD,$EC
;for which
0406B6 00DD 00EC ;various tones
0406BA 0107 012A .WORD $107,$12A,$14C,$165
;are generated.
0406BE 014C 0165
![Page 13: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/13.jpg)
MUSIC SYNTHESIZER INTERFACE
13
4.5 DEMONSTRATION PROGRAM FOR ESA 196 TRAINER
;Assume the interface is connected over J1 of the trainer.
;The trainer can be in KEYBOARD MODE or SERIAL MODE.
REGA EQU 52H
REGC EQU 54H
REGD EQU 56H
REGE EQU 58H
REGM EQU 60H
REGT EQU 62H
REGZ EQU 64H
PORT_A EQU 200H
PORT_B EQU 202H
PORT_C EQU 204H
CMD_PORT EQU 206H
GET_CH EQU 22E6H
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
8000 B1 80 52 LDB REGA,#80H ;Initialise 8255
8003 C7 01 06 02 STB REGA,CMD_PORT ;for mode 0.
8007 52 ;All Ports O/P.
8008 B1 4F 60 RDSTAT: LDB REGM,#4FH ;Bit 7 of Port C
800B A1 78 80 62 LD REGT,#FREQTB ;is made high
800F FD NOP
8010 B1 00 64 BACK: LDB REGZ,#00
8013 EF D0 A2 LCALL GET_CH ;Get keycode to
;20H register.
8016 99 39 20 CMPB 20H,#39H ;Routine to
8019 D9 0A JH DOWN ;check the
801B 99 2F 20 CMPB 20H,#2FH ;key pressed
801E D1 F0 JNH BACK ;must be in
8020 79 30 20 SUBB 20H,#30H ;between
8023 20 0D SJMP DISP ;0 to 9 &
8025 99 40 20 DOWN: CMPB 20H,#40H ;A to F.
8028 D1 E6 JNH BACK
802A 99 46 20 CMPB 20H,#46H
802D D9 E1 JH BACK
802F 79 37 20 SUBB 20H,#37H
8032 98 64 20 DISP: CMPB 20H,REGZ ;Key pressed
8035 DF 08 JE NXTPLS ;is valid
8037 17 64 INCB REGZ ;then take
8039 07 62 INC REGT ;the count from
803B 27 F5 SJMP DISP ;FREQTB.
![Page 14: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/14.jpg)
MUSIC SYNTHESIZER INTERFACE
14
803D 27 C9 LOOP1: SJMP RDSTAT
803F B1 00 52 NXTPLS: LDB REGA,#00
8042 C7 01 04 02 STB REGA,PORT_C
8046 52
8047 B2 62 54 LDB REGC,[REGT]
804A FD NXTPRD: NOP ;Delay Routine.
804B FD NOP
804C B1 01 56 LDB REGD,#01H
804F 15 56 REPT: DECB REGD
8051 99 00 56 CMPB REGD,#00
8054 D7 F9 JNE REPT
8056 E0 54 F1 DJNZ REGC,NXTPRD
8059 B1 FF 52 LDB REGA,#0FFH
805C C7 01 04 02 STB REGA,PORT_C
8060 52
8061 C4 54 62 STB REGT,REGC
8064 FD NXT: NOP ;Delay Routine.
8065 FD NOP
8066 B1 01 58 LDB REGE,#01H
8069 15 58 REPT1: DECB REGE
806B 99 00 58 CMPB REGE,#00
806E D7 DF JNE REPT
8070 E0 54 F1 DJNZ REGC,NXT
8073 E0 60 C9 DJNZ REGM,NXTPLS
8076 27 C5 SJMP LOOP1
8078 B7 A8 96 85 FREQTB: DCB B7H,0A8H,96H,85H,7EH,70H,64H,59H
807C 7E 70 64 59
8080 54 4A 42 3E DCB 54H,4AH,42H,3EH,37H,31H,2CH,29H
8084 37 31 2C 29
4.6 DEMONSTRATION PROGRAM FOR ESA 86/88-2 TRAINER
; Assume the interface is connected over J4 of the trainer.
; The trainer can be in KEYBOARD MODE or SERIAL MODE.
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
2000 BA EB FF START: MOV DX,FFEBH ;Configure 8279 for
2003 B0 04 MOV AL,04H ;Encoded scan
2005 EE OUT DX,AL ;sensor matrix
;mode.
2006 B0 30 MOV AL,30H ;program clock
2008 EE OUT DX,AL ;of 8279
![Page 15: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/15.jpg)
MUSIC SYNTHESIZER INTERFACE
15
2009 BA EB FF NXTKEY: MOV DX,FFEBH
200C B0 C1 MOV AL,0C1H ;Clear 8279 buffer
200E EE OUT DX,AL
200F BA EB FF RDSTAT: MOV DX,FFEBH
2012 B0 E0 MOV AL,0E0H
2014 EE OUT DX,AL
2015 EC IN AL,DX ;Get status word to
2016 24 40 AND AL,40H ;accumulator
;If any key is
;pressed bit 6 is
;set
2018 3C 40 CMP AL,40H ;Check if key is
;pressed
201A 75 F3 JNZ RDSTAT ;No read status
201C B1 00 MOV CL,00
201E B0 50 MOV AL,50H ;configure 8279 in
2020 EE OUT DX,AL ;auto increment
;mode
2021 BA E9 FF MOV DX,FFE9H
2024 EC IN AL,DX
2025 0A C0 OR AL,AL
2027 75 07 JNZ GETKEY ;Check if any key
;is pressed
2029 FE C1 INC CL
202B EC IN AL,DX
202C 0A C0 OR AL,AL ;if no key is
;pressed wait
202E 74 D0 JZ START ;till a key is
;pressed
2030 B5 00 GETKEY: MOV CH,00
2032 F9 STC
2033 F5 CMC
2034 D0 C8 SHRAGN: ROR AL,1
2036 72 04 JC KEYCOD
2038 FE C5 INC CH
203A EB F8 JMP SHRAGN
203C 8A C1 KEYCOD: MOV AL,CL ;Get key code
;to accumulator
203E 24 1F AND AL,1FH
2040 D0 C0 ROL AL,1 ;shift left 3 times
2042 D0 C0 ROL AL,1
2044 D0 C0 ROL AL,1
2046 02 C5 ADD AL,CH
2048 BB 81 20 MOV BX,OFFSET FREQTB ;BX is points
;to beginning of
![Page 16: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/16.jpg)
MUSIC SYNTHESIZER INTERFACE
16
;the table
204B 02 C3 ADD AL,BL ;Add key code
;to BL,and
204D 8A D8 MOV BL,AL ;BX will point to
;frequency
;for the key pressed
204F B0 80 MOV AL,80H ;Initialize 8255 ports
2051 BA E7 FF MOV DX,0FFE7H ;as output ports
2054 EE OUT DX,AL
2055 B1 4F MOV CL,4FH
2057 B0 00 NXTPLS: MOV AL,0 ;Output low to port C
2059 BA E5 FF MOV DX,0FFE5H
205C EE OUT DX,AL
205D 8A 2F MOV CH,[BX] ;Get frequency to CH
205F 90 NXTPRD: NOP ;Dummy instructions
;for delay
2060 90 NOP
2061 90 NOP
2062 90 NOP
2063 90 NOP
2064 90 NOP
2065 FE CD DEC CH
2067 75 F6 JNZ NXTPRD
2069 B0 FF MOV AL,0FFH ;Output high to portC
206B BA E5 FF MOV DX,0FFE5H
206E EE OUT DX,AL
206F 8A 2F MOV CH,[BX] ;Get frequency to CH
2071 90 NXT: NOP
2072 90 NOP
2073 90 NOP
2074 90 NOP
2075 90 NOP
2076 90 NOP
2077 FE CD DEC CH
2079 75 F6 JNZ NXT
207B FE C9 DEC CL
207D 75 D8 JNZ NXTPLS
207F EB 8E JMP RDSTAT ;Check if key is
;still pressed
2081 B7 AB 96 85 7E 70 64 FREQTB DB 0B7H,0ABH,96H,85H,7EH,
59 54 4A 42 3E 37 31 70H,64H,59H,54H,4AH,
2C 29 42H,3EH,37H,31H,2CH,29H
4.7 DEMONSTRATION PROGRAM FOR ESA-51 TRAINER
![Page 17: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/17.jpg)
MUSIC SYNTHESIZER INTERFACE
17
;Assume the interface is connected over J10 of the trainer.
;The trainer can be KEYBOARD MODE or SERIAL MODE.
;Press keys A to P in the key board to generate the musical
;tones
GET_KB EQU 161H
GETCH EQU 12BBH
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
ORG 8000H
8000 75 A0 E8 MOV P2,#0E8H
8003 79 03 MOV R1,#03H ;INITIALISE
;THE PORTS
8005 74 80 MOV A,#80H ;AS O/PS
8007 F3 MOVX @R1,A
8008 90 E9 04 START: MOV DPTR,#0E904H
800B E0 MOVX A,@DPTR
800C 30 E3 05 JNB ACC.3,SERIAL
800F 12 01 61 LCALL GET_KB ;GET THE KEY
;CODE
8012 80 03 SJMP CHECK
8014 12 12 BB SERIAL: LCALL GETCH
8017 F5 F0 CHECK: MOV B,A
8019 B4 41 00 CJNE A,#41H,L1 ;CHECK IT'S
;B/W A&P
801C 40 EA L1: JC START
801E B4 51 00 CJNE A,#51H,L2
8021 50 E5 L2: JNC START
8023 54 0F ANL A,#0FH ;GET THE
;OFFSET
8025 C0 E0 PUSH A
8027 E5 F0 MOV A,B
8029 30 E4 06 JNB ACC.4,GET
802C D0 E0 POP A
802E 24 10 ADD A,#10H
8030 80 02 SJMP GET1
8032 D0 E0 GET: POP A
8034 90 80 6C GET1: MOV DPTR,#FREQTB
8037 25 82 ADD A,DPL
8039 F5 82 MOV DPL,A ;ADD THE
;OFFSET TO
;THE DPTR &
;GET THE
![Page 18: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/18.jpg)
MUSIC SYNTHESIZER INTERFACE
18
;REQUIRED
;FREQUENCY
803B 7B 4F MOV R3,#04FH
803D 74 00 NXTPLS: MOV A,#00H
803F 78 02 MOV R0,#02H
8041 75 A0 E8 MOV P2,#0E8H
8044 F2 MOVX @R0,A
8045 E4 CLR A
8046 93 MOVC A,@A+DPTR
8047 FC MOV R4,A
8048 1D NXTPRD: DEC R5
8049 1D DEC R5
804A 1D DEC R5
804B 1D DEC R5
804C 1D DEC R5
804D 1C DEC R4
804E BC 00 F7 CJNE R4,#0,NXTPRD
8051 74 FF MOV A,#0FFH
8053 78 02 MOV R0,#02H
8055 75 A0 E8 MOV P2,#0E8H
8058 F2 MOVX @R0,A
8059 E4 CLR A
805A 93 MOVC A,@A+DPTR
805B FC MOV R4,A
805C 1D NEXT: DEC R5
805D 1D DEC R5
805E 1D DEC R5
805F 1D DEC R5
8060 1D DEC R5
8061 1D DEC R5
8062 1C DEC R4
8063 BC 00 F6 CJNE R4,#0,NEXT
8066 1B DEC R3
8067 BB 00 D3 CJNE R3,#0,NXTPLS
806A 80 9C SJMP START
806C 00 B7 A8 96 FREQTB: DB 00H,0B7H,0A8H,96H
8070 85 7E 70 64 DB 85H,7EH,70H,64H
8074 59 54 4A 42 DB 59H,54H,4AH,42H
8078 3E 37 31 2C DB 3EH,37H,31H,2CH,29H
807D 29
4.8 DEMONSTRATION PROGRAM FOR ESA 86/88-3 TRAINER
![Page 19: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/19.jpg)
MUSIC SYNTHESIZER INTERFACE
19
; The program assumes that the interface is connected over FRC
; connector J8 of the trainer.
; The program can be executed in STAND-ALONE MODE or SERIAL
; MODE of operation.
; The program starts at memory location 0:2000H
; Please refer ESA 86/88-3 user's manual for mnemonic syntax
; suitable to trainer
Code Segment :0000H
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
2000 B8 00 00 MOV AX,0000H ;Initialise
;Segment
2003 8E C0 MOV ES,AX ;Registers
2005 8B C8 MOV CX,AX
2007 BA E6 FF MOV DX,0FFE6H ;Initialise all
200A B0 80 MOV AL,80H ;8255 Ports as
;o/p in Mode 0
200C EE OUT DX,AL
200D 9A A9 00 00 FB GETKEY: CALL FAR 0FB00:00A9H ;Read key
;from ASCII KBD
2012 B9 00 00 MOV CX,0000H ;Clear count &
;initialise
2015 BE 00 25 MOV SI,2500H ;pointer to frqy
;table
2018 3C 41 CMP AL,41H ;Check if key
;value
201A 72 F1 JB GETKEY ;falls bet'n 'A'
;and 'P'
201C 3C 50 CMP AL,50H
201E 7F ED JG GETKEY ;Accept valid
;key only
2020 BA E4 FF MOV DX,0FFE4H ;Compute count
2023 2C 41 SUB AL,41H ;value from
;ASCII keycode
2025 8A C8 MOV CL,AL
2027 80 F9 00 FREQ: CMP CL,00H
202A 74 08 JE NEXT ;Increment index
;register
202C 46 INC SI ;to point to
;proper value
202D FE C9 DEC CL ;in frequency
;table
202F E9 F5 FF JMP FREQ
![Page 20: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/20.jpg)
MUSIC SYNTHESIZER INTERFACE
20
2032 E2 F3 LOOP FREQ
2034 8A 2C NEXT: MOV CH,[SI] ;Load desired
;frequency
2036 B1 4F MOV CL,4FH ;in CX register
; Routine to generate tone of desired frequency
2038 B0 00 NXTPLS: MOV AL,00H
203A EE OUT DX,AL ;Output LOW to
;Port C
203B 90 N1: NOP ;Dummy
;instructions
203C 90 NOP ; for delay
203D 90 NOP
203E 90 NOP
203F 90 NOP
2040 90 NOP
2041 FE CD DEC CH
2043 75 F6 JNZ N1
2045 8A 2C MOV CH,[SI] ;Get frequency
;to CH
2047 F6 D0 NOT AL ;Output HIGH to
;Port C
2049 EE OUT DX,AL
204A 90 N2:NOP ;Dummy
;instructions
204B 90 NOP ;for delay
204C 90 NOP
204D 90 NOP
204E 90 NOP
204F 90 NOP
2050 FE CD DEC CH
2052 75 F6 JNZ N2
2054 FE C9 DEC CL ;Repeat process
;according
2056 75 E0 JNZ NXTPLS ;to frequency
2058 E9 B2 FF JMP GETKEY ;Read next key &
;continue
2500 ORG 2500H
2500 FC E4 D2 C4 B0 A2 DB FCH,E4H,D2H,C4H,B0H,A2H,94H,80H
2506 94 80
2508 74 6A 52 42 3E 27 DB 74H,6AH,52H,42H,3EH,27H,1CH,0FH
250E 1C 0F
4.9 DEMONSTRATION PROGRAM FOR ESA-51E TRAINER
![Page 21: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/21.jpg)
MUSIC SYNTHESIZER INTERFACE
21
;Assumes the interface is connected over J5 of the trainer.
;The trainer can be in KEYBOARD MODE or in SERIAL MODE
;Press keys A to P in the key board to generate the musical
;tones
GETKB EQU 0142H
GETCH EQU 12A5H
OUTSTG EQU 11E0H
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
8000 ORG 8000H
8000 75 A0 E8 MOV P2,#0E8H
8003 79 03 MOV R1,#03H ;INITIALISE PORTS
;AS O/PS
8005 74 80 MOV A,#80H
8007 F3 MOVX @R1,A
8008 90 E1 02 START: MOV DPTR,#0E102H
800B E0 MOVX A,@DPTR
800C 30 E3 05 JNB ACC.3,SERIAL
800F 12 01 42 LCALL GETKB ;GET THE KEY CODE
8012 80 09 SJMP CHECK
8014 90 80 83 SERIAL: MOV DPTR,#MSG
8017 12 11 E0 LCALL OUTSTG
801A 12 12 A5 LCALL GETCH
801D F5 F0 CHECK: MOV B,A
801F B4 41 00 CJNE A,#41H,L1 ;CHECK IT'S B/W
;A&P
8022 40 E4 L1: JC START
8024 B4 51 00 CJNE A,#51H,L2
8027 50 DF L2: JNC START
8029 54 0F ANL A,#0FH ;GET THE OFFSET
802B C0 E0 PUSH A
802D E5 F0 MOV A,B
802F 30 E4 06 JNB ACC.4,GET
8032 D0 E0 POP A
8034 24 10 ADD A,#10H
8036 80 02 SJMP GET1
8038 D0 E0 GET: POP A
803A 90 80 72 GET1: MOV DPTR,#FREQTB
803D 25 82 ADD A,DPL
803F F5 82 MOV DPL,A ;ADD THE OFFET TO THE
;DPTR &GET THE
;REQUIRED FREQUENCY
8041 7B 4F MOV R3,#04FH
![Page 22: Intel's MCS-51 family of microcontrollers and its ... · MUSIC SYNTHESIZER INTERFACE 3 The interface module has a 26-pin connector at one edge of the card. This is used for connecting](https://reader031.vdocument.in/reader031/viewer/2022021811/5c88d57b09d3f23d648c20c4/html5/thumbnails/22.jpg)
MUSIC SYNTHESIZER INTERFACE
22
8043 74 00 NXTPLS: MOV A,#00H
8045 78 02 MOV R0,#02H
8047 75 A0 E8 MOV P2,#0E8H
804A F2 MOVX @R0,A
804B E4 CLR A
804C 93 MOVC A,@A+DPTR
804D FC MOV R4,A
804E 1D NXTPRD: DEC R5
804F 1D DEC R5
8050 1D DEC R5
8051 1D DEC R5
8052 1D DEC R5
8053 1C DEC R4
8054 BC 00 F7 CJNE R4,#0,NXTPRD
8057 74 FF MOV A,#0FFH
8059 78 02 MOV R0,#02H
805B 75 A0 E8 MOV P2,#0E8H
805E F2 MOVX @R0,A
805F E4 CLR A
8060 93 MOVC A,@A+DPTR
8061 FC MOV R4,A
8062 1D NEXT: DEC R5
8063 1D DEC R5
8064 1D DEC R5
8065 1D DEC R5
8066 1D DEC R5
8067 1D DEC R5
8068 1C DEC R4
8069 BC 00 F6 CJNE R4,#0,NEXT
806C 1B DEC R3
806D BB 00 D3 CJNE R3,#0,NXTPLS
8070 80 96 SJMP START
8072 00 B7 A8 96 FREQTB: DB 00H,0B7H,0A8H,96H
8076 85 7E 70 64 DB 85H,7EH,70H,64H
807A 59 54 4A 42 DB 59H,54H,4AH,42H
807E 3E 37 31 2C 29 DB 3EH,37H,31H,2CH,29H
8083 0D 0A 50 52 45 MSG: DB 0DH,0AH,'PRESS KEY',0H
8088 53 53 20 4B 45
808D 59 00