Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- timer0:
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- #define TONEOUT P1_7 ;auf Port 1 pin 7 kommt der Ton raus
- #define reloadvalue 5536
- ;------------------------------------------------------------------------------
- ; 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, T1_ISR, T1_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
- 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:
- ANL TMOD, #~(T1_MASK_)
- ORL TMOD, #(T1_M0_)
- RET
- PlayTone:
- CJNE R0,#255,tone
- jmp over
- tone: MOV TH0,R0
- MOV TL0,R0
- SETB TR0
- over: RET
- PlayNote:
- CALL PlayTone
- MOV TL1,#HIGH(reloadvalue)
- MOV TH1,#LOW(reloadvalue)
- SETB TR1
- RET
- ;------------------------------------------------------------------------------
- ; T0 Interrupt Sevice Routine
- ;------------------------------------------------------------------------------
- USING 0 ; state register_bank used
- ; for the following program code.
- T0_ISR:
- PUSH PSW
- PUSH Acc
- MOV a,#17
- INC t0count
- CJNE a,t0count,loop
- CPL TONEOUT
- MOV t0count,#0
- loop: POP Acc
- POP PSW
- RETI
- T1_ISR:
- PUSH PSW
- PUSH Acc
- MOV TL1,#HIGH(reloadvalue)
- MOV TH1,#LOW(reloadvalue)
- DJNZ R1,loop2
- CLR TR0
- CLR TR1
- loop2: POP Acc
- POP PSW
- RETI
- END ; End Of File
- ;-----------------------------------------------------------------
- ;main:
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- #include "notedefines.h" ; include notedefines.h
- #define TONEOUT P1_7 ;auf Port 1 pin 7 kommt der Ton raus
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME MAIN_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- EXTRN CODE (T0_INIT, T1_INIT, PlayNote, lied)
- ;------------------------------------------------------------------------------
- ; 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.
- 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
- CALL T0_INIT
- CALL T1_INIT
- SETB EA ;enable all interrupts
- SETB ET0 ;enable Timer0
- SETB ET1 ;enable Timer1
- MOV DPTR,#lied ; adresse der jeweiligen tonhoehe bzw. laenge in dtpr kopieren
- loop: CLR A ; clear akku, wegen movc in der nächsten zeile
- MOVC a,@a+dptr ; noten-wert bzw. laenge aus cem Codespeicher in den akku speichern
- JZ loop2 ; wenn akku = 0, dann ist das ende des lieds erreicht und er springt auf JMP $
- MOV R0,a ; die tonhöhe in R0 speichern
- INC DPTR ; dptr inkrementieren --> nächste adresse, wo sich tonhoehe bzw. laenge befinden, in dtpr kopieren
- CLR A ; clear akku, wegen movc in der nächsten zeile
- MOVC a,@a+dptr ; noten-wert bzw. laenge aus cem Codespeicher in den akku speichern
- MOV R1,a ; die tonlaenge in R1 speichern
- INC DPTR ; dptr inkrementieren --> nächste adresse, wo sich tonhoehe bzw. laenge befinden, in dtpr kopieren
- CALL PlayNote ; ruft das unterprogramm PlayNote auf
- JB TR1,$ ; springt auf die selbe Zeile, wenn TR1 gesetzt ist --> geht erst weiter, wenn die Note zu ende gespielt ist
- JMP loop ; springt zum label loop
- loop2: JMP $ ;wenn programmende springt es immer auf diese zeile
- ;------------------------------------------------------------------------------
- ; 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
- ;-------------------------------------------------------------------
- ;mission impossible
- ;------------------------------------------------------------------------------
- ; 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 lied
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement