Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- MOV R0,#A4
- MOV R1,#VIERTEL
- ;------------------------------------------------------------------------------
- ; Insert your assembly program here. Note, the code below is non-functional.
- ;------------------------------------------------------------------------------
- CALL T0_INIT
- CALL T1_INIT
- CALL PlayTone
- CALL PlayNote
- JMP $
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- basemonitor:
- ;------------------------------------------------------------------------------
- ; 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
- 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
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC T0_ISR, T0_INIT, PlayTone
- ;------------------------------------------------------------------------------
- ; 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
- PlayTone:
- MOV TH0,R0
- MOV TL0,R0
- SETB TR0
- 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
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- timer1:
- ;------------------------------------------------------------------------------
- ; 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 Timer1_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- T1_data_seg SEGMENT DATA
- RSEG T1_data_seg ; switch to this code segment
- t0count: DS 1
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC T1_ISR, T1_INIT, PlayNote
- ;------------------------------------------------------------------------------
- ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
- ;------------------------------------------------------------------------------
- T1_code_seg SEGMENT CODE
- RSEG T1_code_seg ; switch to this code segment
- ;------------------------------------------------------------------------------
- ; init T0 to ....
- ;------------------------------------------------------------------------------
- USING 0 ; state register_bank used
- ; for the following program code.
- T1_INIT:
- ANL TMOD, #~(T1_MASK_) // Was ist den die Maske für Mod1 laden?
- ORL TMOD, #(T1_M1_) //
- RET
- PlayNote:
- ;------------------------------------------------------------------------------
- ; T0 Interrupt Sevice Routine
- ;------------------------------------------------------------------------------
- USING 0 ; state register_bank used
- ; for the following program code.
- T1_ISR:
- PUSH PSW
- CLR TR0 // Timer0 stoppen
- POP PSW
- RETI
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- notesdefine.h:
- // 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 4 //4*150 = 600ms(da man ja 600dez nicht laden kann)
- #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
Advertisement
Add Comment
Please, Sign In to add comment