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

📄 tic.lst

📁 aduc842原程序代码 ad公司芯片应用笔记
💻 LST
字号:
TIC                                                                                                           PAGE 1

                       1    ;********************************************************************
                       2    ;
                       3    ; Author        : ADI - Apps            www.analog.com/MicroConverter
                       4    ;
                       5    ; Date          : October 2003
                       6    ;
                       7    ; File          : TIC.asm
                       8    ;
                       9    ; Hardware      : ADuC842/ADuC843
                      10    ;
                      11    ; Description   : Demonstrates a use of a timer interval counter for 
                      12    ;               counting longer intervals than the standard 8052 
                      13    ;               timers are capable of.
                      14    ;               
                      15    ;               The LED will, on power up, flash at 6.4Hz. By pressing
                      16    ;               the external interrupt button INT0 the counter will 
                      17    ;               count how long the button is pressed correct to 
                      18    ;               1/128th of a second. When released the program will 
                      19    ;               flash the light at the measured time correct only to
                      20    ;               the nearest unit (1/128s, seconds, minutes or hours)
                      21    ;               rounded DOWN.
                      22    ;               eg) If the button was pressed for 0.91000s the light
                      23    ;               would complement every 0.90625s (less than 1 second
                      24    ;               therefore it measures in 1/128s and the nearest unit 
                      25    ;               less than 0.91000s is 0.90625s). However if the light
                      26    ;               was on for 1.6s it complements every 1s as the nearest
                      27    ;               unit is now the second.
                      28    ;               Pressing the INT0 button again will record a new 
                      29    ;               time interval which will flash the light in the same
                      30    ;               way.
                      31    
                      32    ;********************************************************************
                      33    
                      34    $MOD842                         ; Use 8052&ADuC842 predefined symbols
                      35    
  00B4                36    LED     EQU     P3.4            ; P3.4 drives red LED on eval board
  00B2                37    BUTTON  EQU     P3.2            ; P3.2 drives the INT0 button on the
                      38                                    ; eval board
                      39    
                      40    ;____________________________________________________________________
                      41                                                      ; BEGINNING OF CODE
----                  42    CSEG
                      43    
0000                  44    ORG 0000h
                      45    
0000 020060           46            JMP     MAIN            ; jump to main program
                      47    
                      48    ;____________________________________________________________________
                      49                                        ; EXTERNAL INTERRUPT VECTOR SPACE
0003                  50    ORG 0003h ;  (INT0 ISR)                 
                      51    
0003 C2B4             52            CLR     LED             ; Turn ON the LED while the INT0 
                      53                                    ; is pressed
                      54    
                      55    ; reset all counters and then start counting    
0005 53A1FE           56            ANL     TIMECON, #0FEh  ; Clear the TCEN bits to clear the
                      57                                    ; registers; 
                      58                                    ;  -Hthsec
TIC                                                                                                           PAGE 2

                      59                                    ;  -sec
                      60                                    ;  -min
                      61                                    ;  -hour.
                      62                                    ; and to clears the internal counter
                      63    
0008 43A101           64            ORL     TIMECON, #01h  ; Set the TCEN bit to restart counting
                      65    
000B 30B2FD           66            JNB     BUTTON, $       ; Wait here while button is pressed
                      67    
000E 53A1FD           68            ANL     TIMECON, #0FDh  ; Clear the TIEN bit to stop the 
                      69                                    ; counter
                      70    
                      71    ; after button is released we can store the value in intval 
                      72    
0011 D2B4             73    LOOP:   SETB     LED             ; Turn off LED to indicate that the 
                      74                                    ; button is released.
0013 E5A5             75            MOV     A, HOUR         
0015 B40028           76            CJNE    A, #00H, HOURS  ; Check if any hrs have been counted
                      77                                    ; If so jump to HOURS
0018 E5A4             78            MOV     A, MIN                  
001A B40019           79            CJNE    A, #00H, MINS   ; Check if any mins have been counted
                      80                                    ; If so jump to MINS
001D E5A3             81            MOV     A, SEC
001F B4000A           82            CJNE    A, #00H, SECS   ; Check if any secs have been counted
                      83                                    ; If so jump to SECS
                      84            
0022 85A2A6           85    HUNTHS: MOV     INTVAL, HTHSEC  ;load the value of HTHSEC into INTVAL
0025 75A100           86            MOV     TIMECON, #00h   ; clear TCEN to reset the registers
0028 75A103           87            MOV     TIMECON, #03H   ; change TIMECON to measure in 1/128s
                      88                                    ; reset TIEN
002B 32               89            RETI
                      90    
002C 85A3A6           91    SECS:   MOV     INTVAL, SEC     ; load the value of SEC into INTVAL
002F 75A100           92            MOV     TIMECON, #00h   ; clear TCEN to reset the registers
0032 75A113           93            MOV     TIMECON, #13H   ; change TIMECON to measure in secs
0035 32               94            RETI
                      95    
0036 85A4A6           96    MINS:   MOV     INTVAL, MIN     ; load the value of MIN into INTVAL
0039 75A100           97            MOV     TIMECON, #00h   ; clear TCEN to reset the registers
003C 75A123           98            MOV     TIMECON, #23H   ; change TIMECON to measure in mins
003F 32               99            RETI
                     100    
0040 85A5A6          101    HOURS:  MOV     INTVAL, HOUR    ; load the value of HOUR onto INTVAL
0043 75A100          102            MOV     TIMECON, #00h   ; clear TCEN to reset the registers
0046 75A133          103            MOV     TIMECON, #33H   ; change TIMECON to measure in hours
0049 32              104            RETI
                     105    ;____________________________________________________________________
                     106                                             ; TII INTERRUPT VECTOR SPACE
0053                 107    ORG 0053h
                     108           
0053 B2B4            109            CPL LED                 ; Complement the LED every time the 
                     110                                    ; measured time runs up.
0055 32              111            RETI
                     112    ;_____________________________________________________________________
                     113    
0060                 114    ORG 0060h
                     115    
0060                 116    MAIN:   
TIC                                                                                                           PAGE 3

                     117    
                     118    ; Configure Time Interval Counter  
0060 75D707          119            MOV    PLLCON,#07H    ; Allow sufficient time for instructions to execute
0063 75A103          120            MOV    TIMECON, #03h  ; initialise timecon to count in 1/128s
                     121                                  ; -set TCEN to enable the time clock
                     122                                  ; -set TIEN to enable the TIC 
                     123                                  ; -clear STI to allow automatic relaod
                     124                                  ;  of interval timeout 
                     125                                  ; -clear TFH to disable 24 hr counting
                     126    
0066 75A60A          127            MOV    INTVAL, #0Ah   ; initialise to blink LED every 10 units
                     128                                  ; the units are 1/128s          
                     129    
                     130    ; Configure External Interrupt
0069 D288            131            SETB    IT0            ; INT0 edge triggered
006B D2A8            132            SETB    EX0            ; enable INT0 (button on eval board)
006D 75A904          133            MOV     IEIP2,#04H     ; enable time interval interrupt
                     134            
0070 D2AF            135            SETB    EA             ; enable global interrupts
                     136    
                     137    
0072 80FE            138            JMP     $              ; wait here for interrupts
                     139                                   ; main program can be inserted here
                     140            
                     141    ;____________________________________________________________________
                     142    
                     143    END

VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
TIC                                                                                                           PAGE 4

BUTTON . . . . . . . . . . . . .    NUMB  00B2H  
EA . . . . . . . . . . . . . . .  B ADDR  00AFH  PREDEFINED  
EX0. . . . . . . . . . . . . . .  B ADDR  00A8H  PREDEFINED  
HOUR . . . . . . . . . . . . . .  D ADDR  00A5H  PREDEFINED  
HOURS. . . . . . . . . . . . . .  C ADDR  0040H  
HTHSEC . . . . . . . . . . . . .  D ADDR  00A2H  PREDEFINED  
HUNTHS . . . . . . . . . . . . .  C ADDR  0022H  NOT USED  
IEIP2. . . . . . . . . . . . . .  D ADDR  00A9H  PREDEFINED  
INTVAL . . . . . . . . . . . . .  D ADDR  00A6H  PREDEFINED  
IT0. . . . . . . . . . . . . . .  B ADDR  0088H  PREDEFINED  
LED. . . . . . . . . . . . . . .    NUMB  00B4H  
LOOP . . . . . . . . . . . . . .  C ADDR  0011H  NOT USED  
MAIN . . . . . . . . . . . . . .  C ADDR  0060H  
MIN. . . . . . . . . . . . . . .  D ADDR  00A4H  PREDEFINED  
MINS . . . . . . . . . . . . . .  C ADDR  0036H  
P3 . . . . . . . . . . . . . . .  D ADDR  00B0H  PREDEFINED  
PLLCON . . . . . . . . . . . . .  D ADDR  00D7H  PREDEFINED  
SEC. . . . . . . . . . . . . . .  D ADDR  00A3H  PREDEFINED  
SECS . . . . . . . . . . . . . .  C ADDR  002CH  
TIMECON. . . . . . . . . . . . .  D ADDR  00A1H  PREDEFINED  

⌨️ 快捷键说明

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