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

📄 ic_card.s43

📁 使用MSP430系列单片机开发的低功耗转速测量系统
💻 S43
📖 第 1 页 / 共 2 页
字号:
		ret
;;-------------------------------------------------------	
security_8data
		bic.b   #ic_data,&P1DIR
		bic.b   #ic_clk,&P1OUT
		clr     R9
security_next_data
		mov.b   #08h,&counter
security_out_8bit
		bis.b   #ic_clk,&P1OUT
		nop
		nop
		nop
		bit.b   #ic_data,&P1IN
		jz      security_bit_0
		bis.b   #80h,&com_byte
		jmp     security_bit_deal
security_bit_0
		bic.b   #80h,&com_byte
security_bit_deal
		rrc.b   &com_byte
		bic.b   #ic_clk,&P1OUT
		call    #delay_8us
		dec.b   &counter	
		jnz     security_out_8bit
		mov.b   &com_byte,ic_read_data(R9)
		inc     R9
		cmp     #4h,R9
		jnz     security_next_data
		ret
	 	
;;----------------------------------------------------
processing_256
                bic.b   #ic_clk,&P1OUT 
                bic.b   #ic_data,&P1DIR
                mov.b   #255,&counter                  
loop_255	
                bis.b   #ic_clk,&P1OUT                     
		call    #delay_8us 
		bic.b   #ic_clk,&P1OUT                     
		call    #delay_8us 
		dec.b   &counter 
		jnz     loop_255
                ret           

delay_50us
                call    #delay_8us
                call    #delay_8us
                ret
delay_8us
                nop
                nop
                nop
                nop
                nop
                nop
                nop
                nop
                nop
                nop
                nop
                ret 

;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;------------------------------------- 
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     
;;------------------------------------- 
remain_water_display
              	bit       	#negative_water_1stbit,&system_flag1
              	jnz       	remain_negative_water_display
          
              	mov       	&water_remain1,&hex_low_word
              	mov       	&water_remain2,&hex_high_word
              	call      	#hex_to_bcd
              	call      	#show_clr 
              	mov       	&bcd_low_word,&display_word1
              	mov       	&bcd_high_word,&display_word2
              	call      	#lcd_display_on
              	bis.b           #h,&lcdmem+2 		
              	ret   
remain_negative_water_display
             	mov      	&water_remain1,&water_negative1
             	mov      	&water_remain2,&water_negative2
             	inv      	&water_negative1
             	inv      	&water_negative2
             	inc      	&water_negative1
             	adc      	&water_negative2
             	mov      	&water_negative1,&hex_low_word
             	mov      	&water_negative2,&hex_high_word
             	call     	#hex_to_bcd
             	call     	#show_clr 
             	mov      	&bcd_low_word,&display_word1
             	mov      	&bcd_high_word,&display_word2
             	call     	#lcd_display_on                      	
             	clr.b      	&lcdmem 
                bis.b      	#g,&lcdmem  
                bis.b      	#h,&lcdmem+2 
              	ret
;;-------------------------------------
buy_water_display
              	mov       	&water_purchase1,&hex_low_word
              	mov       	&water_purchase2,&hex_high_word
              	call      	#hex_to_bcd
              	call      	#show_clr 
              	mov       	&bcd_low_word,&display_word1
              	mov       	&bcd_high_word,&display_word2
              	call      	#lcd_display_on
                bis.b           #h,&lcdmem			
              	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"    
;;--------------------------------------------------------------        
hex_to_bcd      clr    		&bcd_high_word
              	clr    		&bcd_low_word
              	clr    		R5
;;------最最最高位的转换
              	mov    		&hex_high_word,R5
              	swpb   		R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	and    		#0Fh,R5
              	jz     		most_most_middle1
most_most_higher 
              	clrc             
              	dadd   		#5456h,&bcd_low_word
              	dadd   		#6843h,&bcd_high_word
              	dec    		R5
              	jnz    		most_most_higher 
;;------最最最高位中间位的转换  
most_most_middle1
              	mov    		&hex_high_word,R5
              	swpb   		R5
              	and    		#0Fh,R5
              	jz     		most_highest
most_most_middle
              	clrc             
              	dadd   		#7216h,&bcd_low_word
              	dadd   		#1677h,&bcd_high_word
              	dec    		R5
              	jnz    		most_most_middle                
;;------最最高位的转换
most_highest    mov    		&hex_high_word,R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	and    		#0Fh,R5
              	jz     		bin_bcd_highest1
bin_bcd_most_high
              	clrc
              	dadd   		#08576h,&bcd_low_word
              	dadd   		#104h,&bcd_high_word
              	dec    		R5
              	jnz    		bin_bcd_most_high            
;;------最高位的转换
bin_bcd_highest1
              	mov    		&hex_high_word,R5
              	and    		#0Fh,R5
              	jz     		bin_bcd_higher1
bin_bcd_highest
              	clrc
              	dadd   		#05536h,&bcd_low_word
              	dadd   		#6,&bcd_high_word
              	dec    		R5
              	jnz    		bin_bcd_highest
              	
;;------次高位的转换  
bin_bcd_higher1
              	mov    		&hex_low_word,R5
              	swpb   		R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	and    		#0Fh,R5
              	jz     		bin_bcd_middle1
bin_bcd_higher 
              	clrc             
              	dadd   		#4096h,&bcd_low_word
              	dadc   		&bcd_high_word
              	dec    		R5
              	jnz    		bin_bcd_higher 
;;------中间位的转换  
bin_bcd_middle1
              	mov    		&hex_low_word,R5
              	swpb   		R5
              	and    		#0Fh,R5
              	jz     		bin_bcd_lower1
bin_bcd_middle
              	clrc             
              	dadd   		#256h,&bcd_low_word
              	dadc   		&bcd_high_word
              	dec    		R5
              	jnz    		bin_bcd_middle
;;------次低位的转换               
bin_bcd_lower1   
              	mov    		&hex_low_word,R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	rrc    		R5
              	and    		#0Fh,R5
             	jz     		bin_bcd_lowest1
bin_bcd_lower
              	clrc             
              	dadd   		#16h,&bcd_low_word
              	dadc   		&bcd_high_word
                dec     	R5
                jnz     	bin_bcd_lower                         
;;------最低位的转换  
bin_bcd_lowest1
              	mov    		&hex_low_word,R5
              	and    		#0Fh,R5
              	jz     		bin_bcd_end
bin_bcd_lowest
              	clrc             
              	dadd   		#1h,&bcd_low_word
              	dadc   		&bcd_high_word
               	dec    		R5
              	jnz    		bin_bcd_lowest
bin_bcd_end
              	ret                    	
;************************************************************************************************
; Interrupt Vector Table
;************************************************************************************************
    ORG   0FFE0h     
    DW    rtc_deal   	;  0FFE0h: Basic Timer1
    DW    MAIN_T     ;  0FFE2h: I/O Port 2   
    DW    MAIN_T     	;  0FFE4h: not used
    DW    MAIN_T     	;  0FFE6h: not used
    DW    port_int1     ;  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    MAIN_T 	;  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 + -