⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doorbell.lst

📁 proteus 仿真实例
💻 LST
📖 第 1 页 / 共 4 页
字号:
MPASM 03.00 Released         DOORBELL.ASM   7-9-2002  10:52:24         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001               LIST    p=16F84 ; PIC16F844 is the target processor
                      00002 
                      00003               #include "P16F84.INC" ; Include header file
                      00001         LIST
                      00002 ; P16F84.INC  Standard Header File, Version 2.00    Microchip Technology, Inc.
                      00136         LIST
                      00004 
                      00005               CBLOCK 0x10   ; Temporary storage
  00000010            00006               tempo
  00000011            00007               tptrl
  00000012            00008               tptrh
  00000013            00009               note
  00000014            00010               length
  00000015            00011               pitch
  00000016            00012               temp              
  00000017            00013               dl1
  00000018            00014               dl2              
                      00015               ENDC
                      00016 
                      00017 
0000                  00018               ORG   0
0000   2805           00019 entrypoint    goto  initialise
                      00020 
0004                  00021               ORG   4
0004   2870           00022 intvector     goto    toggle
                      00023 
0005                  00024 initialise    ; Register set up:
0005   0103           00025               clrw                    ; Zero.
0006   0085           00026               movwf   PORTA           ; Ensure PORTB is zero before we enable it.               
0007   0086           00027               movwf   PORTB           ; Ensure PORTB is zero before we enable it.
0008   1683           00028               bsf     STATUS,RP0      ; Select Bank 1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0009   0186           00029               clrf    TRISB           ; Port B is outputs              
                      00030 
                      00031               ; Set up timer 0 for tone generation
000A   3002           00032               movlw   0x02            ; Prescaler on, internal clocking, divide by 4            
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
000B   0081           00033               movwf   OPTION_REG
000C   1283           00034               bcf     STATUS,RP0      ; Back to bank 0                              
                      00035               
                      00036                                 
                      00037               ; Poll for a button
000D   0186           00038 wait          clrf    PORTB
000E   1C05           00039 wloop         btfss   PORTA,0
000F   2813           00040               goto    playtune0
0010   1C85           00041               btfss   PORTA,1
0011   281C           00042               goto    playtune1
0012   280E           00043               goto    wloop                                   
                      00044 
                      00045 ;Routines to play the tunes
0013   3013           00046 playtune0     movlw   0x13
0014   0086           00047               movwf   PORTB
0015   3050           00048               movlw   0x50
MPASM 03.00 Released         DOORBELL.ASM   7-9-2002  10:52:24         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0016   0090           00049               movwf   tempo
0017   3000           00050               movlw   tune0 / 0x100
0018   0092           00051               movwf   tptrh
0019   3080           00052               movlw   tune0 % 0x100
001A   0091           00053               movwf   tptrl
001B   2825           00054               goto    playtune
                      00055 
001C   3023           00056 playtune1     movlw   0x23
001D   0086           00057               movwf   PORTB
001E   30A0           00058               movlw   0xA0
001F   0090           00059               movwf   tempo
0020   3001           00060               movlw   tune1 / 0x100
0021   0092           00061               movwf   tptrh
0022   3042           00062               movlw   tune1 % 0x100
0023   0091           00063               movwf   tptrl
0024   2825           00064               goto    playtune
                      00065                   
                      00066 ;Subroutine to play a tune
0025   2045           00067 playtune      call    gettunedata       ; Lookup note from tune table
0026   0093           00068               movwf   note              ; Store the note code
0027   1B93           00069               btfsc   note,7            ; Bit 7 set => end of tune
0028   280D           00070               goto    wait              ; Back to waiting for a button press
0029   0A91           00071               incf    tptrl,F           ; Increment the tune pointer
002A   2045           00072               call    gettunedata       ; Get the note length
002B   0094           00073               movwf   length            ; Store it
                      00074                                                                              
                      00075 ; Play the stored note
                      00076 ; The tune table supports two octaves and 8 note lengths.
002C   1B13           00077 playnote      btfsc   note,6            ; Bit 6 set => rest
002D   2836           00078               goto    playwait          ; Silence ensues...     
002E   0813           00079               movf    note,W            ; Retrieve the note           
002F   393F           00080               andlw   0x3F              ; Mask off the pitch index
0030   2049           00081               call    pitchtable        ; and look it up in the pitchtable
0031   0095           00082               movwf   pitch             ; Transfer the value to Timer 0
0032   0081           00083               movwf   TMR0
0033   110B           00084               bcf     INTCON,T0IF       ; Clear Timer Interrupt
0034   168B           00085               bsf     INTCON,T0IE       ; Enable interrupts for Timer 0
0035   178B           00086               bsf     INTCON,GIE
0036   0814           00087 playwait      movf    length,W          ; Retrieve the note length
0037   0097           00088               movwf   dl1               ; and store it in delay counter 1
0038   0810           00089 loop1         movf    tempo,W           ; This value sets the timing resolution
0039   0098           00090               movwf   dl2
003A   0000           00091 loop2         nop                       ; Inner delay loop delay
003B   0000           00092               nop      
003C   0B98           00093               decfsz  dl2,F             
003D   283A           00094               goto    loop2
003E   0B97           00095               decfsz  dl1,F             ; Outer delay loop 
003F   2838           00096               goto    loop1
0040   128B           00097               bcf     INTCON,T0IE       ; Timer interrupts off            
                      00098 
                      00099 ;Fetch next note/length pair:
0041   0A91           00100               incf    tptrl,F           ; Increment tune ptr          
0042   1903           00101               btfsc   STATUS,Z          ; Test for low byte rollover
MPASM 03.00 Released         DOORBELL.ASM   7-9-2002  10:52:24         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0043   0A92           00102               incf    tptrh,F           ; Inc high byte
0044   2825           00103               goto    playtune          ; Loop for next note
                      00104 
                      00105 ; Routine to fetch data from the tune tables
0045   0812           00106 gettunedata   movf    tptrh,W         ; Set up PCLATH for the jump
0046   008A           00107               movwf   PCLATH                      
0047   0811           00108               movf    tptrl,W         ; Get low address of tptr
0048   0082           00109               movwf   PCL             ; Jump off to the table entry                                   
                      00110 
                      00111 ; Pitch lookup function                                      
0049   018A           00112 pitchtable    clrf    PCLATH           ; Clear PCLATH for zero page
004A   0782           00113               addwf PCL,F
004B   3411           00114               retlw 0x11               ;C5  // Midi Code 60
004C   341F           00115               retlw 0x1F               ;C#
004D   342B           00116               retlw 0x2B               ;D
004E   3437           00117               retlw 0x37               ;D#
004F   3442           00118               retlw 0x42               ;E
0050   344D           00119               retlw 0x4D               ;F
0051   3457           00120               retlw 0x57               ;F#
0052   3461           00121               retlw 0x61               ;G
0053   346A           00122               retlw 0x6A               ;G#
0054   3472           00123               retlw 0x72               ;A (440)
0055   347A           00124               retlw 0x7A               ;Bb
0056   3481           00125               retlw 0x81               ;B
0057   3489           00126               retlw 0x89               ;C6 // Midi Code 72
0058   348F           00127               retlw 0x8F               ;Db
0059   3496           00128               retlw 0x96               ;D
005A   349C           00129               retlw 0x9C               ;Eb
005B   34A1           00130               retlw 0xA1               ;E
005C   34A7           00131               retlw 0xA7               ;F
005D   34AC           00132               retlw 0xAC               ;F#
005E   34B0           00133               retlw 0xB0               ;G
005F   34B5           00134               retlw 0xB5               ;Ab
0060   34B9           00135               retlw 0xB9               ;A (880)
0061   34BD           00136               retlw 0xBD               ;Bb
0062   34C1           00137               retlw 0xC1               ;B
0063   34C4           00138               retlw 0xC4               ;C7 // Midi Code 84
0064   34C8           00139               retlw 0xC8               ;Db
0065   34CB           00140               retlw 0xCB               ;D
0066   34CE           00141               retlw 0xCE               ;Eb
0067   34D1           00142               retlw 0xD1               ;E
0068   34D3           00143               retlw 0xD3               ;F
0069   34D6           00144               retlw 0xD6               ;F#
006A   34D8           00145               retlw 0xD8               ;G
006B   34DA           00146               retlw 0xDA               ;Ab
006C   34DC           00147               retlw 0xDC               ;A (1760)
006D   34DE           00148               retlw 0xDE               ;Bb
006E   34E0           00149               retlw 0xE0               ;
006F   34E2           00150               retlw 0xE2               ;C8 // Midi Code 96
                      00151 
                      00152                                                                     
                      00153               
                      00154 
MPASM 03.00 Released         DOORBELL.ASM   7-9-2002  10:52:24         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00155 ;Interrupt service - toggle the drive polarity to the sounder
                      00156 ;Note that this does not preserve the status bits - be careful,
                      00157 ;and that there is an assumption we are addressing bank 0.
0070   0096           00158 toggle        movwf   temp
0071   0815           00159               movf    pitch,W
0072   0081           00160               movwf   TMR0
0073   0806           00161               movf    PORTB,W
0074   3A0F           00162               xorlw   0x0F
0075   0086           00163               movwf   PORTB
0076   110B           00164               bcf     INTCON,T0IF
0077   0816           00165               movf    temp,w
0078   0009           00166               retfie
                      00167 
                      00168 ;Tune Tables             
                      00169 ;Must be on even byte boundary                        
                      00170                         
0080                  00171               org 0x0080
                      00172 
                      00173 ; Tune 0 Data
                      00174 ; Bach 'Badinerie' from Suite No 2
0080   3417           00175 tune0   retlw 0x17      ;B
0081   3478           00176         retlw 0x78      ;240
0082   341A           00177         retlw 0x1A      ;D
0083   343C           00178         retlw 0x3C      ;120
0084   3417           00179         retlw 0x17      ;B
0085   343C           00180         retlw 0x3C      ;120
0086   3412           00181         retlw 0x12      ;F#
0087   3478           00182         retlw 0x78      ;240
0088   3417           00183         retlw 0x17      ;B
0089   343C           00184         retlw 0x3C      ;120
008A   3412           00185         retlw 0x12      ;F#
008B   343C           00186         retlw 0x3C      ;120
008C   340E           00187         retlw 0x0E      ;D
008D   3478           00188         retlw 0x78      ;240
008E   3412           00189         retlw 0x12      ;F#
008F   343C           00190         retlw 0x3C      ;120
0090   340E           00191         retlw 0x0E      ;D
0091   343C           00192         retlw 0x3C      ;120
0092   340B           00193         retlw 0x0B      ;B
0093   34F0           00194         retlw 0xF0      ;480
0094   3406           00195         retlw 0x06      ;F#
0095   343C           00196         retlw 0x3C      ;120
0096   340B           00197         retlw 0x0B      ;B
0097   343C           00198         retlw 0x3C      ;120
0098   340E           00199         retlw 0x0E      ;D
0099   343C           00200         retlw 0x3C      ;120
009A   340B           00201         retlw 0x0B      ;B
009B   343C           00202         retlw 0x3C      ;120
009C   340D           00203         retlw 0x0D      ;C#
009D   343C           00204         retlw 0x3C      ;120

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -