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

📄 adc.asm

📁 TMS320LF2407显示子程序,将16进制转化为十进制,然后分别显示在4个LED上
💻 ASM
字号:
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ;this is a source file of ADC and airthmetic module
 ;update:03/01/04 
 ;author: wangqing jiang
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
stack:      .usect    "stack",32     ;setup stack for interrupt   location:0060~006Fh
A_CON:      .usect    "temper",1
B_CON:      .usect    "temper",1
C_CON:      .usect    "temper",1 
result:     .usect    "temper",1          
RESULT:     .usect    "temper",1
COUNTER:    .usect    "temper",1     
BEICHU:     .usect    "temper",1
CHU:        .usect    "temper",1 
TEM1:       .usect    "temper",5   
AMORTIZE:   .usect    "temper",1
TEM2:       .usect    "temper",1

          .include    f2407.h
          .global     start
          ;.global     adc_int1 
          .global     PHANTOM  
          
          
KING_DOG .macro
       LDP        #DP_PF1
       SPLK       #05555h,WDKEY
       SPLK       #0AAAAh,WDKEY 
       .endm


    .text

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; configure the system control  and status registers
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
start: 
     CALL        SYS_INIT
     CALL        SPI_INIT
     CALL        SPI_DISPLAY_INIT
     LACL        #9871    ;将9871h的内容装载入ACC
     SACL        BEICHU
     CALL        ADC_DISPLAY 
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
    
     
     
     
     LACL        #9999
     SACL        BEICHU
     CALL        ADC_DISPLAY
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
    
     
     LACL        #0000
     SACL        BEICHU
     CALL        ADC_DISPLAY
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
     CALL        DELAY_LONG
    
     
WAIT:
     NOP
     B    WAIT      
     

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;system initialize
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          
SYS_INIT:     
     SETC        INTM
     CLRC        SXM
     CLRC        OVM
     CLRC        CNF
     LDP         #DP_PF1
     SPLK        #81FDh,SCSR1
     SPLK        #00E8h,WDCR
     LDP         #DP_B2
     SPLK        #0000h,IMR
     SPLK        #0FFFFh,IFR 
          RET
     
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;spi initialize
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
SPI_INIT: 
     LDP         #DP_PF1
     SPLK        #004Fh,SPICCR    ;ENABLE SPI REGISTER BE INTIAL AND 16BIT OUT允许SPI初始化
     SPLK        #0006h,SPICTL    ;MASTER WORK CONDITION
     SPLK        #0027H,SPIBRR    ;SPI BODE RATE =1MHz    cpu=40Mhz    spibrr=27h
     SPLK        #00CFh,SPICCR    ;DISABLE SPI INITAL
     LDP         #DP_PF2       
     SPLK        #003Ch,MCRB
     
           RET 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~
;spi display initialize
;~~~~~~~~~~~~~~~~~~~~~~~~~~~

SPI_DISPLAY_INIT:
     LDP         #DP_B2
     SPLK        #0C01h,COUNTER            ;#SHUT_DOWN_ON,COUNTER 
     CALL        SEND_LED_CTRL  
     
     SPLK        #0B03h,COUNTER            ;#SCAN_LIMIT_3,SPI_CON 
     CALL        SEND_LED_CTRL 
                                            
     SPLK        #0A0Dh,COUNTER            ;#INTENSITY_CTRL_F,SPI_CON 
     CALL        SEND_LED_CTRL  
                   
     SPLK        #0900h,COUNTER            ;#NO_CODE_DIG0_7,SPI_CON           
     CALL        SEND_LED_CTRL
                    
     SPLK        #0F01h,COUNTER            ;#DISPLAY_TEST_ON,SPI_CON 
     CALL        SEND_LED_CTRL 
                   
     SPLK        #0F00h,COUNTER            ;#DISPLAY_TEST_OFF,SPI_CON 
     CALL        SEND_LED_CTRL 
                   

SEND_LED_CTRL:    
     LACL        COUNTER
     LDP         #DP_PF1
     SACL        SPITXBUF 
LOOP_TEST:         
     BIT         SPISTS,BIT6
     BCND        LOOP_TEST,NTC   
     LACC        SPIRXBUF             ;CLEAR THE SPI INT FLAG
     LDP         #DP_B2
          RET

     
;~~~~~~~~~~~~~~~~~~~~~~~~~~
;arithmetic
;~~~~~~~~~~~~~~~~~~~~~~~~~~ 

ADC_DISPLAY:       
           
     LDP        #DP_B2
     LAR        AR3,#TEM1        ;AR3 restore the data which will be displayed
     ;LACL       RESULT 
     MAR        *,AR3
;the first division  ,1000                             
     SPLK       #1000,CHU    
     ZAC                         
     LACL       BEICHU            
     RPT        #15
     SUBC       CHU                
     SACL       *+                
     SACH       BEICHU
          
;the second division   ,100  
     SPLK       #100,CHU    
     ZAC                         
     LACL       BEICHU            
     RPT        #15
     SUBC       CHU                
     SACL       *+                
     SACH       BEICHU 
     
;the third division   ,10  
     SPLK       #10,CHU    
     ZAC                         
     LACL       BEICHU            
     RPT        #15
     SUBC       CHU                
     SACL       *+                
     SACH       BEICHU 
     
;the fourth division   ,1 
     LACL       BEICHU
     SACL       * 
           
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;display
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                           
                   
DISPLAY:
    LDP        #DP_B2
    LAR        AR3,#TEM1          ;AR3 restore the data which will be displayed                       
    MAR        *,AR3  
    
    ZAC
    LACC       *+ 
    ADD        #DIGIT_BANK         
    TBLR       COUNTER 
    LACL       COUNTER
    ADD        #0100h
    SACL       COUNTER
    CALL       SEND_LED_CTRL       ;display the content to digit_0
    
    ZAC
    LACC       *+ 
    ADD        #DIGIT_BANK        
    TBLR       COUNTER 
    LACL       COUNTER
    ADD        #0200h
    SACL       COUNTER
    CALL       SEND_LED_CTRL       ;display the content to digit_1
    
    ZAC
    LACC       *+ 
    ADD        #DIGIT_BANK        
    TBLR       COUNTER
    LACL       COUNTER
    ADD        #0300h
    SACL       COUNTER
    CALL       SEND_LED_CTRL       ;display the content to digit_2
    
    ZAC
    LACC       * 
    ADD        #DIGIT_BANK        
    TBLR       COUNTER
    LACL       COUNTER
    ADD        #0400h
    SACL       COUNTER
    CALL       SEND_LED_CTRL       ;display the content to digit_3
    
          RET           




DELAY:                       
                   LACC      #99000
DELAY1:            SUB       #1
                   RPT       #79
                   NOP       
                   BCND      DELAY1,NEQ
                   RET
                   
DELAY_LONG         LACC      #25
DELAY_LONG1:       SUB       #1 
                   PUSH      ACC
                   CALL      DELAY 
                   POP       ACC
                   BCND      DELAY_LONG1,NEQ
                   RET   
     
     
    
PHANTOM:
     RET     
     
            
                    
DIGIT_BANK:
       .word      0077h       ; 0             
       .word      0014h       ; 1
       .word      00E6h       ; 2
       .word      00B6h       ; 3
       .word      0095h       ; 4
       .word      00B3h       ; 5
       .word      00F3h       ; 6
       .word      0016h       ; 7
       .word      00F7h       ; 8
       .word      00B7h       ; 9
       
       
   .end    
       

⌨️ 快捷键说明

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