Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Notesdefine:
- // Definition der Zähler für die Töne und die Tonlängen
- #define B3 //233,03 Hz
- #define H3 //246,96 Hz
- #define C4 //261,63 Hz
- #define D4 //293,66 Hz
- #define Es4 //311,13 Hz
- #define E4 //329,63 Hz
- #define F4 //349,23 Hz
- #define G4 //392,00 Hz
- #define A4 114 //440 Hz
- #define H4 //493,88 Hz
- #define C5 //523,25 Hz
- #define D5 //587,33 Hz
- #define E5 //659,26 Hz
- //100mps
- #define Viertel 20 // 20*30ms=600ms
- //#define VIERTEL_PUNKT
- #define Achtel 10 // 10*30ms = 300ms
- #define Sechzehntel 5 // 5*30 = 150ms
- #define Ganze 80 // 80*30 = 2400ms
- #define Halbe 40 // 40*30 = 1200ms
- #define Pause 80
- /*
- #define VIERTEL 4 //4*150 = 600ms
- #define VIERTEL_PUNKT
- #define ACHTEL 2 // 2*150 = 300ms
- #define SECHZENTEL 1 // 1*150 = 150ms
- #define GANZE 16 // 16*150 = 2400ms
- #define HALBE 8 // 8*150 = 1200ms
- */
- MissionImpossible:
- ;------------------------------------------------------------------------------
- ; Source code template for A251/A51 assembler modules.
- ; Copyright (c) 1995-2000 KEIL Software, Inc.
- ;------------------------------------------------------------------------------
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME MissionImpossible
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- #include <notedefines.h>
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC notes
- mission_data SEGMENT CODE
- // Hier wird der RAM mit den entsprechenden Konstanten für das Lied
- // Mission Impossible Theme geladen
- RSEG mission_data
- lied:
- DB C5
- DB Achtel
- DB A4
- DB Achtel
- DB E4
- DB Ganze
- DB C5
- DB Achtel
- DB A4
- DB Achtel
- DB Es4
- DB Ganze
- DB C5
- DB Achtel
- DB A4
- DB Achtel
- DB D4
- DB Ganze
- DB C4
- DB Achtel
- DB D4
- DB Sechzehntel
- DB Pause
- DB Sechzehntel
- DB Pause
- DB Ganze
- DB C4
- DB Achtel
- DB Pause
- DB Viertel
- DB C4
- DB Achtel
- DB Pause
- DB Viertel
- DB Es4
- DB Viertel
- DB F4
- DB Viertel
- DB C4
- DB Achtel
- Db Pause
- DB Viertel
- DB C4
- DB Achtel
- DB Pause
- DB Viertel
- DB B3
- DB Achtel
- DB Pause
- DB Achtel
- DB H3
- DB Achtel
- DB Pause
- DB Achtel
- DB C4
- DB Achtel
- DB Pause
- DB Viertel
- DB C4
- DB Achtel
- DB Pause
- DB Viertel
- DB Es4
- DB Viertel
- DB F4
- DB Viertel
- DB C4
- DB Achtel
- Db Pause
- DB Viertel
- DB C4
- DB Achtel
- DB Pause
- DB Viertel
- // 00 gibt an, dass das Lied zu Ende ist
- DB 00
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- basemon:
- ;------------------------------------------------------------------------------
- ; set Reset and other Vectors to Monitor needs
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME BASE_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- EXTRN CODE (start) ; May be a subroutine entry declared in
- ; CODE segments or with CODE directive.
- EXTRN CODE (T0_ISR, T1_ISR)
- ;------------------------------------------------------------------------------
- ; Provide an LJMP to start at the reset address (address 0) in the main module.
- ; You may use this style for interrupt service routines.
- ;------------------------------------------------------------------------------
- CSEG AT 0x8000 ; absolute Segment at Address 0x8000
- JMP start ; reset location (jump to start)
- ;------------------------------------------------------------------------------
- ; Provide an LJMP to T0 Interrupt Service Routine
- ;------------------------------------------------------------------------------
- CSEG AT 0x800B ; absolute Segment at Address 0x800B
- JMP T0_ISR ; T0 Interrupt Service Routine
- CSEG AT 0x801B
- JMP T1_ISR
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- main:
- ;------------------------------------------------------------------------------
- ; Source code template for A251/A51 assembler modules.
- ; Copyright (c) 1995-2000 KEIL Software, Inc.
- ;------------------------------------------------------------------------------
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- #include "notedefines.h"
- ;auf Port 1 pin 7 kommt der Ton raus
- #define TONEOUT P1_7
- ;------------------------------------------------------------------------------
- ; Change names in lowercase to suit your needs.
- ;
- ; This assembly template gives you an idea of how to use the A251/A51
- ; Assembler. You are not required to build each module this way-this is only
- ; an example.
- ;
- ; All entries except the END statement at the End Of File are optional.
- ;
- ; If you use this template, make sure you remove any unused segment declarations,
- ; as well as unused variable space and assembly instructions.
- ;
- ; This file cannot provide for every possible use of the A251/A51 Assembler.
- ; Refer to the A51/A251 User's Guide for more information.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME MAIN_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- EXTRN CODE (T0_INIT, PlayTone, T1_INIT, PlayNote)
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC start
- ;------------------------------------------------------------------------------
- ; Put the STACK segment in the main module.
- ;------------------------------------------------------------------------------
- ?STACK SEGMENT IDATA ; ?STACK goes into IDATA RAM.
- RSEG ?STACK ; switch to ?STACK segment.
- DS 5 ; reserve your stack space
- ; 5 bytes in this example.
- ;------------------------------------------------------------------------------
- ; Put segment and variable declarations here.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; DATA SEGMENT--Reserves space in DATA RAM--Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; XDATA SEGMENT--Reserves space in XDATA RAM--Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; INPAGE XDATA SEGMENT--Reserves space in XDATA RAM page (page size: 256 Bytes)
- ; INPAGE segments are useful for @R0 addressing methodes.
- ; Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; ABSOLUTE XDATA SEGMENT--Reserves space in XDATA RAM at absolute addresses.
- ; ABSOLUTE segments are useful for memory mapped I/O.
- ; Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; BIT SEGMENT--Reserves space in BIT RAM--Delete segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Add constant (typeless) numbers here.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
- ;------------------------------------------------------------------------------
- main_code_seg SEGMENT CODE
- RSEG main_code_seg ; switch to this code segment
- USING 0 ; state register_bank used
- ; for the following program code.
- start: MOV SP,#?STACK-1 ; assign stack at beginning
- SETB EA ;enable all interrupts
- SETB ET0 ;enable 1 interrupt namens ET0
- ;------------------------------------------------------------------------------
- ; Insert your assembly program here. Note, the code below is non-functional.
- ;------------------------------------------------------------------------------
- CALL T0_INIT
- CALL T1_INIT
- loop: MOV dptr,#lied
- MOVC a,@a+dptr
- MOV R0,a
- inc lied
- mov dptr,#lied
- MOVC a,@a+dptr
- MOV R1,a
- inc lied
- CALL PlayNote
- cjne a,#0,loop
- JMP $
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- timer0:
- ;------------------------------------------------------------------------------
- ; Source code template for A251/A51 assembler modules.
- ; Copyright (c) 1995-2000 KEIL Software, Inc.
- ;------------------------------------------------------------------------------
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- #define TONEOUT P1_7
- ;------------------------------------------------------------------------------
- ; Change names in lowercase to suit your needs.
- ;
- ; This assembly template gives you an idea of how to use the A251/A51
- ; Assembler. You are not required to build each module this way-this is only
- ; an example.
- ;
- ; All entries except the END statement at the End Of File are optional.
- ;
- ; This file cannot provide for every possible use of the A251/A51 Assembler.
- ; Refer to the A51/A251 User's Guide for more information.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME Timer0_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- T0_data_seg SEGMENT DATA
- RSEG T0_data_seg ; switch to this code segment
- t0count: DS 1
- t1count: DS 1
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC T0_ISR, T0_INIT, PlayTone, PlayNote
- ;------------------------------------------------------------------------------
- ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
- ;------------------------------------------------------------------------------
- T0_code_seg SEGMENT CODE
- RSEG T0_code_seg ; switch to this code segment
- ;------------------------------------------------------------------------------
- ; init T0 to ....
- ;------------------------------------------------------------------------------
- USING 0 ; state register_bank used
- ; for the following program code.
- T0_INIT:
- ANL TMOD, #~(T0_MASK_)
- ORL TMOD, #(T0_M1_)
- MOV t0count,#0
- RET
- T1_INIT:
- //timer 1 - mode1 laden
- PlayTone:
- MOV TH0,R0
- MOV TL0,R0
- SETB TR0
- RET
- PlayNote:
- CALL PlayTone
- MOV TH0,xx ;braucht man das überhaupt, weil laut mitschrift braucht der 16-bit timer bis zum overflow 30ms?
- MOV THL,xx
- SETB TR1
- RET
- ;------------------------------------------------------------------------------
- ; T0 Interrupt Sevice Routine
- ;------------------------------------------------------------------------------
- USING 0 ; state register_bank used
- ; for the following program code.
- T0_ISR:
- PUSH PSW
- MOV a,#16
- INC t0count
- CJNE a,t0count,loop
- CPL TONEOUT
- MOV t0count,#0
- loop: POP PSW
- RETI
- T1_ISR:
- PUSH PSW
- MOV a,#R0
- INC t1count
- CJNE a,t1count,loop2
- SETB TR0
- SETB TR1
- loop2: POP PSW
- RETI
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement