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

📄 read_head.inc

📁 em4100的解码程序
💻 INC
📖 第 1 页 / 共 2 页
字号:
;-----------------------------------------------------                       ;
;       read_head
;-----------------------------------------------------        
	;这个是以上升沿检测
	

		;------------------提起同步信号,同时得到第一个数据	
read_head:	;
		nop
	waitfist:	
		snz		rfid			;rfid=1,skip
		jmp		first
		jmp		waitfist
	
first:	;rfid=0,检测第一个上升沿前是不是有T的时间的低电平?
		
		mov		a,48
		call	delay_30us
		sz		rfid
		jmp		first_rise
		
		mov		a,20
		call	delay_30us
		sz		rfid
		jmp		first_rise
		
		mov		a,48
		call	delay_30us
		sz		rfid
		jmp		first_rise
		
		mov		a,20
		call	delay_30us
		sz		rfid
		jmp		first_rise
		
		
		jmp		error			;一个T的时间内没有跳变,则出错
		
		;------------------检测到第一个上升沿,并保存得到的第一个数据
first_rise:	;rfid=1
		set		c				;因为这是以检测上沿,所以置1
		set		con_receive		;保存这个状态的值,为下一位做准备
	store_head_data:		
		rlc		head0
		rlc		head1
		sdz		head_count		;head_count=0,skip
		jmp		read_em4100_data
		jmp		head_data_over
					
				;rfid=1,wait for rfid=0
read_em4100_data:				
		mov		a,48
		call	delay_30us
		snz		rfid			;rfid=1,skip
		jmp		half_T_fall
		
		mov		a,20
		call	delay_30us
		snz		rfid
		jmp		half_T_fall
		
		mov		a,48
		call	delay_30us
		snz		rfid			;rfid=1,skip
		jmp		one_T_fall
		
		mov		a,20
		call	delay_30us
		snz		rfid
		jmp		one_T_fall		
		
		jmp		error			;一个T的时间内没有跳变,则出错
		
	;------------------------------第一个上升沿后的第一个下降沿
	;rfid=0,wait for rfid=1
			;----------------------上升沿到下降沿时间为半个位的时间
half_T_fall:					
		mov		a,48
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		half_T_fall_AND_half_T_rsie
		
		mov		a,20
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		half_T_fall_AND_half_T_rsie
				
		mov		a,48
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		half_T_fall_AND_one_T_rise
		
		mov		a,20
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		half_T_fall_AND_one_T_rise
		
		jmp		error			;一个T的时间内没有跳变,则出错
		
		
		;------------------------------第一个上升沿后的第一个下降沿
		;rfid=0,wait for rfid=1
			;----------------------上升沿到下降沿时间为1个位的时间
			
one_T_fall:
		mov		a,48
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		one_T_fall_AND_half_T_rise
		
		mov		a,20
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		one_T_fall_AND_half_T_rise
		
		mov		a,48
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		one_T_fall_AND_one_T_rise
		
		mov		a,20
		call	delay_30us
		sz		rfid			;rfid=0,skip
		jmp		one_T_fall_AND_one_T_rise
		
		jmp		error			;一个T的时间内没有跳变,则出错
;---------------------------------------------------------------------------------		
		;rfid=1,从上一个上升沿到这个上升沿的时间为T
;------------------------------------------------------		
half_T_fall_AND_half_T_rsie:
		
		snz		con_receive		;检测上一个con_receive的状态,con_receive=1,skip
		jmp		T_clr_c			;
		
		set		c
		set		con_receive		;把这个状态保存到con_receive,为下一位做准备
		
		snz		receive_head_over; if=1,head_data is over,skip.
		jmp		store_head_data
		jmp		store_other55_data;
		
	T_clr_c	:
		clr		c
		clr		con_receive		;把这个状态保存到con_receive,为下一位做准备
		
		snz		receive_head_over; if=1,head_data is over,skip.
		jmp		store_head_data
		jmp		store_other55_data;


;-------------------------------------------------------------------------------			
		;rfid=1,从上一个上升沿到这个上升沿的时间为1.5T
;------------------------------------------------------

half_T_fall_AND_one_T_rise:
		nop
one_T_fall_AND_half_T_rise:						
		snz		con_receive		;con_receive=1,skip ,检测上一种状态以确定哪种存储?
		jmp		T1_5_set_c
		
		clr		c				;con_receive=1,得到两个数据为00
		clr		con_receive		;为下一个数做准备,此时是第二个0赋值给C
		
		snz		receive_head_over; if=1,head_data is over,skip.
		jmp		store_head_data_15T
		jmp		store_other55_data_15T;

store_head_data_15T:		
		clr		c
		
		rlc		head0
		rlc		head1
		
		sdz		head_count			;head_count=0,skip
		jmp		store_second0_15T	;保存第二个数据0	
		
		;在此可立一个标示,在head_data_over,进行判断,要不要保存第二个0
		set		second0_15T		;此时若刚好赶上head_count=0,为了保存下一个数据0而立的		
		jmp		head_data_over	;注意head_over=0,也要记得保存第二个0,否则丢掉一个0
		
store_other55_data_15T:
		rlc		data0
		rlc		data1
		rlc		data2
		rlc		data3
		rlc		data4
		rlc		data5
		rlc		data6
		rlc		data7
		rlc		data8
		rlc		data9
		rlc		data10
					
		sdz		data_count
		jmp		store_second0_15T		;保存第二个数据0		
		
		jmp		other55_data_over		;注意此时other55_data_over=0,不用保存第2个0
	
	;;保存第二个数据0	
	store_second0_15T:	
		clr		c
		snz		receive_head_over; if=1,head_data is over,skip.
		jmp		store_head_data_15T_2
		jmp		store_other55_data_15T_2;
		
store_head_data_15T_2:
		clr		c
		clr		con_receive		;为下一个数做准备,此时是第二个0赋值给C
		
		rlc		head0
		rlc		head1
		sdz		head_count				;head_count=0,skip
		jmp		read_em4100_data
		jmp		head_data_over
		
store_other55_data_15T_2:
		clr		c
		clr		con_receive		;为下一个数做准备,此时是第二个0赋值给C
	
		rlc		data0
		rlc		data1
		rlc		data2
		rlc		data3
		rlc		data4
		rlc		data5
		rlc		data6
		rlc		data7
		rlc		data8
		rlc		data9
		rlc		data10
		
		sdz		data_count
		jmp		read_em4100_data		
		jmp		other55_data_over
		
		
		;con_receive=0,得到1个数据为1
	T1_5_set_c:	
		set		c
		set		con_receive		;为下一个数做准备
		
		snz		receive_head_over; if=1,head_data is over,skip		
		jmp		store_head_data
		
		jmp		store_other55_data

;--------------------------------------------------------------------------------
		;rfid=1,从上一个上升到这个上升沿的时间为2T
;---------------------------------------------------------		
one_T_fall_AND_one_T_rise:		;此时得到两个数据01
		clr		c
		
		snz		receive_head_over; if=1,head_data is over,skip.
		jmp		store_head_data_2T_0
		jmp		store_other55_data_2T_0
		
store_head_data_2T_0:			
		clr		c
		
		rlc		head0
		rlc		head1
		sdz		head_count		;head_count=0,skip	
		jmp		store_secnond1_2T_1	;去存储第二个数据1
		
		;在此可立一个标示,在head_data_over,进行判断,要不要保存第二个0
		set		second1_2T	;此时若刚好赶上head_count=0,为了保存下一个数据1而立的
		jmp		head_data_over
		
store_other55_data_2T_0:
		clr		c
		
		rlc		data0
		rlc		data1
		rlc		data2
		rlc		data3
		rlc		data4
		rlc		data5
		rlc		data6
		rlc		data7
		rlc		data8
		rlc		data9
		rlc		data10
		
		sdz		data_count				;data_count=0,skip
		jmp		store_secnond1_2T_1		;去存储第二个数据1
		jmp		other55_data_over
		
	;存储第二个数据1
store_secnond1_2T_1:
		set		c
		set		con_receive				;保存这个状态,为下一位做准备
		
		snz		receive_head_over		; if=1,head_data is over,skip.
		jmp		store_head_data_2T_1
		jmp		store_store_other55_data_2T_1
		
store_head_data_2T_1:
		set		c
		set		con_receive	
		
		rlc		head0
		rlc		head1
		
		sdz		head_count				;head_count=0,skip
		jmp		read_em4100_data
		jmp		head_data_over
					
store_store_other55_data_2T_1:
		set		c
		set		con_receive	
		
		rlc		data0
		rlc		data1
		rlc		data2
		rlc		data3
		rlc		data4
		rlc		data5
		rlc		data6
		rlc		data7
		rlc		data8
		rlc		data9
		rlc		data10
		
		sdz		data_count
		jmp		read_em4100_data
		jmp		other55_data_over
		
		
;-----------------------------------
;		保存数据_55个		
;----------------------------------		
store_other55_data:
		;rlc		head0
		;rlc		head1
		rlc		data0
		rlc		data1
		rlc		data2
		rlc		data3
		rlc		data4
		rlc		data5
		rlc		data6
		rlc		data7
		rlc		data8
		rlc		data9
		rlc		data10
		
		sdz		data_count
		jmp		read_em4100_data		
		
		jmp		other55_data_over

;----------------------------------------------------------
;		data_over
;----------------------------------------------------------		
	;			
head_data_over:
		set		receive_head_over;1:head_data is over,	0:head_data isn't over
		
		mov		a,255
		xor		a,head0
		snz		z				;if result=0,z=1,skip
		jmp		head_data_error
		
		snz		head1.0			;if	head1.0=1,skip
		jmp		head_data_error
		
		;-------------------head_data is ok
		;jmp		$

;***************************************************************************************		
if 0
		;-------------------------300ms
		set		buzz
		mov		a,250
        call    delay_10ms
		;---------------100ms
        mov		a,250
        call    delay_10ms
        ;---------------200ms
        mov		a,250
        call    delay_10ms
        ;--------------------------------
        clr		buzz
        jmp		$
endif        
;*********************************************************************************        
       
        ;--------------------------------  
		
		sz		second0_15T		;next0_15T=0,skip
		jmp		store_second0_15T
		sz		second1_2T		;next1_2T=0,skip
		jmp		store_secnond1_2T_1
		
		jmp		read_em4100_data
	
	;-----------------------------	
other55_data_over:
if 0				
		;-------------------------300ms
		set		buzz
		mov		a,250
        call    delay_10ms
		;---------------100ms
        mov		a,250
        call    delay_10ms
        ;---------------200ms
        mov		a,250
        call    delay_10ms
        ;--------------------------------
        clr		buzz
endif        
       
		;jmp		$
		nop
		
	;--------------------------------------------------
	;	other55_data 的偶校验,停止位
	;--------------------------------------------------
		;----------------------停止位
		sz		s0			;0有效
		jmp		other55_data_error
		
		;-------------------------300ms
		set		buzz
		mov		a,250
        call    delay_10ms
		;---------------100ms
        mov		a,250
        call    delay_10ms
        ;---------------200ms
        mov		a,250
        call    delay_10ms
        ;--------------------------------
        clr		buzz
        
       
		jmp		$
		nop	

		;---------------------10个行校验
			;-----------------p0
		sz		d00				;d00=0,skip
		inc		p0_bit
		
		sz		d01
		inc		p0_bit
		
		sz		d02
		inc		p0_bit
		
		sz		d03
		inc		p0_bit
		
		;sz		p0

⌨️ 快捷键说明

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