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

📄 scanif.s43

📁 使用MSP430系列单片机开发的低功耗转速测量系统
💻 S43
字号:
#include "msp430xW42x.h"         ; standard definition include file
#include "global_vars.h"         ; global variables include file
;********************************************************************/
; Main program 
;********************************************************************/ 
    		ORG     0E000h   
MAIN_T  
    		MOV     	#WDTHOLD+WDTPW,&WDTCTL                                 
    		mov.w   	#300h,SP 
    		MOV.B   	#OSCCAP1+OSCCAP0,&FLL_CTL0    
lo  		BIT.B   	#002h,&FLL_CTL0            
    		JNZ     	lo 
                mov     	#0F000h,R5
osc_wait             
                dec     	R5
                jnz     	osc_wait 
                clr     	R5  
clr_ram_field
                clr.b   	ram_start(R5)
                inc     	R5
                cmp     	#1000,R5
                jnz     	clr_ram_field    		 
init_port               
                mov.b          	#0FFh,&P1DIR  
                mov.b          	#0FFh,&P2DIR    		
    		mov.b 		#0FFh,&P3DIR 
    		mov.b 		#0FFh,&P4DIR  
    		mov.b 		#0FFh,&P5DIR    		     		
     		mov.b 	        #003h,&P6SEL 
     		mov.b 	        #0FCh,&P6DIR   
     		clr.b 		&P6OUT       
     		clr.b 		&P5OUT       
    		clr.b 		&P4OUT        
    		clr.b 		&P3OUT       
    		clr.b 		&P2OUT       
    		clr.b 		&P1OUT     
    		
     		mov    		#26Ch,&SIFDACR0            
     		mov    		#26Ch,&SIFDACR1              
    		mov    		#26Ch,&SIFDACR2          
     		mov    		#26Ch,&SIFDACR3
     		
  		MOV     	#08800h,&SIFTSM0   
  		MOV     	#0002Ch,&SIFTSM1    
		MOV     	#00424h,&SIFTSM2   
		MOV     	#01934h,&SIFTSM3   
		MOV     	#04134h,&SIFTSM4   
		MOV     	#02174h,&SIFTSM5    
		MOV     	#0002Dh,&SIFTSM6 
		MOV     	#00425h,&SIFTSM7   
		MOV     	#01935h,&SIFTSM8   
		MOV     	#04135h,&SIFTSM9   
		MOV     	#02175h,&SIFTSM10   
		MOV     	#00220h,&SIFTSM11  
		clr     	&SIFTSM12
		clr     	&SIFTSM13
		clr     	&SIFTSM14
		clr     	&SIFTSM15
		clr     	&SIFTSM16
		clr     	&SIFTSM17
		clr     	&SIFTSM18
		clr     	&SIFTSM19
		clr     	&SIFTSM20
		clr     	&SIFTSM21
		clr     	&SIFTSM22
		clr     	&SIFTSM23
;;--- Initialize Scan Interface Control Registers
  		MOV    		#0140h,&SIFCTL2      	  
  		call    	#delay857
  		MOV     	#4000h,&SIFCTL3  
  		MOV     	#33F0h,&SIFCTL4     
  		MOV     	#0045h,&SIFCTL5      
  		MOV     	#0FA00h,&SIFPSMV        
  		bis     	#SIFIE3+SIFEN,&SIFCTL1 
Init_real_LCD
     		mov.b   	#0AEh,&BTCTL                 	
     		bic.b   	#BTIFG,&IFG2
     		;bis.b   	#BTIE,&IE2 
     		call    	#totle_water_display 		 
     		eint    
main_loop
     		BIS        	#CPUOFF+SCG1+SCG0+GIE,SR  
     		jmp        	main_loop
; *******************************************************************************************
; *** VSI Interrupt Service Routine                                                        ***
; ********************************************************************************************
SIFIFG_ISR         		      
   		bit     #SIFIE0,&SIFCTL1      
   		jz      test_SIFIFG1         
   		bit     #SIFIFG0,&SIFCTL1     
   		jz      test_SIFIFG1          
   		BIC     #SIFIFG0,&SIFCTL1  
test_SIFIFG1                   
   		bit     #SIFIE1,&SIFCTL1      
   		jz      test_SIFIFG2                                 
   		bit     #SIFIFG1,&SIFCTL1   
   		jz      test_SIFIFG2         
   		BIC     #SIFIFG1,&SIFCTL1    
test_SIFIFG2                     	
   		bit     #SIFIE2,&SIFCTL1     
   		jz      test_SIFIFG3         
   		bit     #SIFIFG2,&SIFCTL1    
   		jz      test_SIFIFG3         
   		BIC     #SIFIFG2,&SIFCTL1     
test_SIFIFG3                     
   		bit     #SIFIE3,&SIFCTL1     
   		jz      test_SIFIFG4        
   		bit     #SIFIFG3,&SIFCTL1 
   		jz      test_SIFIFG4         
   		call    #fw427_update_lcd     
   		BIC     #SIFIFG3,&SIFCTL1    
test_SIFIFG4                     	
   		bit     #SIFIE4,&SIFCTL1      
   		jz      test_SIFIFG5          
   		bit     #SIFIFG4,&SIFCTL1    
   		jz      test_SIFIFG5         
   		BIC     #SIFIFG4,&SIFCTL1 
test_SIFIFG5                    
   		bit     #SIFIE5,&SIFCTL1      
   		jz      test_SIFIFG6         
   		bit     #SIFIFG5,&SIFCTL1    
   		jz      test_SIFIFG6          	
   		BIC     #SIFIFG5,&SIFCTL1            
test_SIFIFG6                         
   		bit     #SIFIE6,&SIFCTL1     
   		jz      end_SIFIFG_ISR        
   		bit     #SIFIFG6,&SIFCTL1         
   		jz      end_SIFIFG_ISR       
   		BIC     #SIFIFG6,&SIFCTL1        
end_SIFIFG_ISR
   		reti        		 
fw427_update_lcd 
        	BIC     #SIFIFG3,&SIFCTL1     
        	mov    	&SIFCNT,&SIF_4_CNT
     		bit     #03h,&SIF_4_CNT
     		jz      Display_Water     	
     		ret		
Display_Water
        	setc
        	dadc    &water_totle1
        	dadc    &water_totle2  		
 		call    #totle_water_display	
        	ret
***********************************************************
; *** delay                                             ***
; *********************************************************
delay857
   		clr.w  		R10
loop
   		cmp.w  		#035Ah,R10
   		jge    		end_delay
   		inc.w  		R10
   		jmp    		loop
end_delay
   		ret     		
;************************************************************************************************
DATA_FA00    ASEG   0FA00h 
    		DB  0x00 
    		DB  0x13 
    		DB  0x0C 
    		DB  0x4D 
    		DB  0x04 
    		DB  0x01 
    		DB  0x4C 
    		DB  0x5B 
    		DB  0x52 
    		DB  0x45 
    		DB  0x08 
    		DB  0x0D 
    		DB  0x44
    		DB  0x05 
    		DB  0x5A 
    		DB  0x09 
    		DB  0x10 
    		DB  0x13 
    		DB  0x4C 
    		DB  0x5B
    		DB  0x44 
    		DB  0x11 
    		DB  0x5A 
    		DB  0x1B 
    		DB  0x12 
    		DB  0x53 
    		DB  0x18 
    		DB  0x4D 
    		DB  0x52 
    		DB  0x45 
    		DB  0x1A 
    		DB  0x19 
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
totle_water_display
              	call      	#show_clr
              	mov       	&water_totle1,&display_word1
              	mov       	&water_totle2,&display_word2
              	call      	#lcd_display_on
              	bis.b           #h,&lcdmem+1		
              	ret 	
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
lcd_display_on
              	mov.b     	#0FCh,&P5SEL                  
              	mov.b     	#LCDON+LCD4MUX+LCDP1,&LCDCTL  
              	clr.b     	R13
              	mov       	&display_word1,com_lcd_data
              	call      	#lcd_bcd_data
              	mov       	&display_word2,com_lcd_data
              	call      	#lcd_bcd_data
              	mov.b     	#08h,&counter
              	call      	#lcd_display_deal
              	ret
lcd_display_deal
              	clr       	R13
              	mov.b     	#7h,R6
next_word_display
              	mov.b     	lcd_buf0(R6),lcdmem(R13)
              	inc       	R13
              	dec       	R6
              	cmp.b     	&counter,R13
              	jnz       	next_word_display  
              	ret 
;;--------------------------------   
lcd_bcd_data           
              	mov.b     	com_lcd_data,&com_byte
              	call      	#full_half
              	swpb      	com_lcd_data
              	mov.b     	com_lcd_data,&com_byte
              	call      	#full_half
              	ret
;;---------------------------------
full_half
              	mov.b     	#0Fh,lcd_buf0(R13)
              	and.b     	&com_byte,lcd_buf0(R13)
              	mov.b     	lcd_buf0(R13),R10
              	mov.b     	lcd_table(R10),lcd_buf0(R13)
              	inc       	R13
              	rrc.b     	&com_byte
              	rrc.b     	&com_byte
              	rrc.b     	&com_byte
              	rrc.b     	&com_byte
              	mov.b     	#0Fh,lcd_buf0(R13)
              	and.b     	&com_byte,lcd_buf0(R13)
              	mov.b     	lcd_buf0(R13),R10
              	mov.b     	lcd_table(R10),lcd_buf0(R13)
              	inc       	R13
              	ret
;;---------------------
show_clr
             	mov     	#16, r5                      ; clear display memory
show_clr1
             	mov.b   	#0,LCDMEM-1(r5)
             	dec     	r5
             	jnz     	show_clr1
             	ret
;;---------------------------------            
;--- character definitions       
lcd_table 
        DB      a+b+c+d+e+f                ; displays "0"
        DB      b+c                        ; displays "1"
        DB      a+b+d+e+g                  ; displays "2"
        DB      a+b+c+d+g                  ; displays "3"
        DB      b+c+f+g                    ; displays "4"
        DB      a+c+d+f+g                  ; displays "5"
        DB      a+c+d+e+f+g                ; displays "6"
        DB      a+b+c                      ; displays "7"
        DB      a+b+c+d+e+f+g              ; displays "8"
        DB      a+b+c+d+f+g                ; displays "9"  	
        DB      a+b+c+e+f+g                ; displays "A"  	
        DB      c+d+e+f+g                  ; displays "b"  	
        DB      a+d+e+f                    ; displays "C"  	
        DB      b+c+d+e+g                  ; displays "d"  	
        DB      a+d+e+f+g                  ; displays "E"
        DB      a+e+f+g                    ; displays "F"         		     
;************************************************************************************************                   	
;************************************************************************************************
; Interrupt Vector Table
;************************************************************************************************
    ORG   0xFFE0    
    DW    MAIN_T   	;  0FFE0h: Basic Timer1
    DW    MAIN_T        ;  0FFE2h: I/O Port 2   
    DW    MAIN_T     	;  0FFE4h: not used
    DW    MAIN_T     	;  0FFE6h: not used
    DW    MAIN_T        ;  0FFE8h: I/O Port 1       
    DW    MAIN_T     	;  0FFEAh: Timer_A0 (CCIFG1\CCIFG2)    
    DW    MAIN_T     	;  0FFECh: Timer_A0 (CCIFG0)
    DW    MAIN_T     	;  0FFEEh: not used    
    DW    MAIN_T     	;  0FFF0h: not used             
    DW    SIFIFG_ISR 	;  0FFF2h: Scan/IF  
    DW    MAIN_T     	;  0FFF4h: Watchdog Timer
    DW    MAIN_T     	;  0FFF6h: Comparator_A
    DW    MAIN_T     	;  0FFF8h: Timer_A1 (CCIFG1\CCIFG2\CCIFG3\CCIFG4)         
    DW    MAIN_T     	;  0FFFAh: Timer_A1 (CCIFG0)
    DW    MAIN_T     	;  0FFFCh: NMI, Osc. Fault, Flash memory   
    DW    MAIN_T     	;  0FFFEh: Power-Up, ext. Reset, Watchdog,Flash mem.
             	
    END

⌨️ 快捷键说明

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