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

📄 ad.s

📁 工业开关量检测模块的原代码,带断线检测功能
💻 S
字号:
	.module ad.c
	.area text(rom, con, rel)
	.dbfile D:\报警系统设计资料\报警系统软件\测量模块基于CAN的系统网程序\电流CAN网\ad.c
	.dbfunc e adreset _adreset fV
;              i -> R20
	.even
_adreset::
	xcall push_gset1
	.dbline -1
	.dbline 7
; #include "main.h"
; 
; unsigned char tempH,tempL;
; int Zero_Data,Full_Data;
; 
; void adreset(void)                          
; {
	.dbline 9
; unsigned char i;
; for(i=0;i<20;i++)                       
	clr R20
	xjmp L11
L8:
	.dbline 10
	.dbline 11
	clr R16
	xcall _spi_write
	.dbline 12
	ldi R16,255
	xcall _spi_write
	.dbline 13
L9:
	.dbline 9
	inc R20
L11:
	.dbline 9
	cpi R20,20
	brlo L8
	.dbline -2
L7:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e init_ad _init_ad fV
;           temp -> R20
	.even
_init_ad::
	xcall push_gset1
	.dbline -1
	.dbline 17
; {
; spi_write(Com_Reg);
; spi_write(0xff);
; }
; }
; 
; void init_ad(void)                     
; { 
	.dbline 20
;   unsigned char temp;
;   
;   adreset();
	xcall _adreset
	.dbline 22
;  
;   spi_write(RD_Id_Reg);                 
	ldi R16,96
	xcall _spi_write
	.dbline 23
;   temp=spi_read();
	xcall _spi_read
	mov R20,R16
	.dbline 25
;   
;   if((temp&0x0f)!=0x0a)
	mov R24,R20
	andi R24,15
	cpi R24,10
	breq L13
	.dbline 26
;   RESET;
	jmp 0x000
	xjmp L14
L13:
	.dbline 28
;   else
;   {
	.dbline 29
;   spi_write(WR_Con_Reg);                
	ldi R16,16
	xcall _spi_write
	.dbline 30
;   spi_write(ConHreg_u_mask|ConHreg_g1_mask);
	ldi R16,18
	xcall _spi_write
	.dbline 31
;   spi_write(ConLreg_buf_mask|ConLreg_buf_mask);
	ldi R16,16
	xcall _spi_write
	.dbline 33
;   
;   spi_write(WR_Io_Reg);                
	ldi R16,40
	xcall _spi_write
	.dbline 34
;   spi_write(0x00);                     
	clr R16
	xcall _spi_write
	.dbline 36
;   
;   spi_write(WR_Mod_Reg);                
	ldi R16,8
	xcall _spi_write
	.dbline 37
;   spi_write(ModHreg_md2_mask);
	ldi R16,128
	xcall _spi_write
	.dbline 38
;   spi_write(ModLreg_fs1_mask);
	ldi R16,2
	xcall _spi_write
L15:
	.dbline 41
L16:
	.dbline 40
;   
;    while(!PINB3)                        
	.dbline 42
;    ;
;   spi_write(RD_Off_Reg);
	ldi R16,112
	xcall _spi_write
	.dbline 43
;   tempH = spi_read();                     
	xcall _spi_read
	sts _tempH,R16
	.dbline 44
;   tempL = spi_read();	                  
	xcall _spi_read
	sts _tempL,R16
	.dbline 45
;   Zero_Data = char_int(tempL,tempH);
	lds R18,_tempH
	xcall _char_int
	sts _Zero_Data+1,R17
	sts _Zero_Data,R16
	.dbline 47
;   
;   spi_write(WR_Con_Reg);                  
	ldi R16,16
	xcall _spi_write
	.dbline 48
;   spi_write(ConHreg_u_mask);
	ldi R16,16
	xcall _spi_write
	.dbline 49
;   spi_write(ConLreg_ref_mask|ConLreg_buf_mask);
	ldi R16,144
	xcall _spi_write
	.dbline 51
;   
;   spi_write(WR_Mod_Reg);                    
	ldi R16,8
	xcall _spi_write
	.dbline 52
;   spi_write(ModHreg_md2_mask|ModHreg_md0_mask);
	ldi R16,160
	xcall _spi_write
	.dbline 53
;   spi_write(ModLreg_fs1_mask);
	ldi R16,2
	xcall _spi_write
L18:
	.dbline 56
L19:
	.dbline 55
	.dbline 57
	ldi R16,120
	xcall _spi_write
	.dbline 58
	xcall _spi_read
	sts _tempH,R16
	.dbline 59
	xcall _spi_read
	sts _tempL,R16
	.dbline 60
	lds R18,_tempH
	xcall _char_int
	sts _Full_Data+1,R17
	sts _Full_Data,R16
	.dbline 62
	ldi R16,16
	xcall _spi_write
	.dbline 63
	ldi R16,16
	xcall _spi_write
	.dbline 64
	ldi R16,144
	xcall _spi_write
	.dbline 66
	ldi R16,8
	xcall _spi_write
	.dbline 67
	clr R16
	xcall _spi_write
	.dbline 68
	ldi R16,2
	xcall _spi_write
	.dbline 69
L14:
	.dbline -2
L12:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r temp 20 c
	.dbend
	.dbfunc e conves_ad _conves_ad fV
;             tt -> R20
	.even
_conves_ad::
	xcall push_gset1
	.dbline -1
	.dbline 75
;   
;    while(!PINB3)                       
;    ;
;   spi_write(RD_Ful_Reg);
;   tempH = spi_read();                     
;   tempL = spi_read();	                 
;   Full_Data = char_int(tempL,tempH);
;   
;   spi_write(WR_Con_Reg);                
;   spi_write(ConHreg_u_mask);
;   spi_write(ConLreg_ref_mask|ConLreg_buf_mask);
;    
;   spi_write(WR_Mod_Reg);                
;   spi_write(0x00); 
;   spi_write(ModLreg_fs1_mask);
;  }
; }
; 
; 
; 
; void conves_ad(void)                      
; {
	.dbline 78
;  unsigned char tt;
;  
;   spi_write(RD_Id_Reg);                  
	ldi R16,96
	xcall _spi_write
	.dbline 79
;   tt = spi_read();
	xcall _spi_read
	mov R20,R16
	.dbline 81
;   
;   if((tt&0x0f)!= 0x0a)
	mov R24,R20
	andi R24,15
	cpi R24,10
	breq L25
	.dbline 82
;   {
	.dbline 83
;   RESET;                                  
	jmp 0x000
	.dbline 84
;   }
	xjmp L23
X0:
	.dbline 86
;   else
;   {
L24:
	.dbline 88
L25:
	.dbline 87
	.dbline 89
	ldi R16,88
	xcall _spi_write
	.dbline 90
	xcall _spi_read
	sts _tempH,R16
	.dbline 91
	xcall _spi_read
	sts _tempL,R16
	.dbline 92
L23:
	.dbline -2
L21:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r tt 20 c
	.dbend
	.dbfunc e char_int _char_int fi
;             tt -> R20,R21
;           data -> R20,R21
;          datah -> R18
;          datal -> R16
	.even
_char_int::
	xcall push_gset1
	.dbline -1
	.dbline 96
;   while(!PINB3)                          
;            ;
;   spi_write(RD_Dat_Reg);	              
;   tempH = spi_read();                     
;   tempL = spi_read();	                  
;     }
;   }
;   
;  unsigned int char_int(uchar datal,uchar datah)
; {
	.dbline 99
;    int data,tt;
;    
;    tt = datah; 
	mov R20,R18
	clr R21
	.dbline 100
;    data = (tt<<8);
	mov R21,R20
	clr R20
	.dbline 101
;    data =  data + datal;
	mov R2,R16
	clr R3
	add R20,R2
	adc R21,R3
	.dbline 102
;    return data;
	movw R16,R20
	.dbline -2
L27:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r tt 20 I
	.dbsym r data 20 I
	.dbsym r datah 18 c
	.dbsym r datal 16 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\报警系统设计资料\报警系统软件\测量模块基于CAN的系统网程序\电流CAN网\ad.c
_Full_Data::
	.blkb 2
	.dbsym e Full_Data _Full_Data I
_Zero_Data::
	.blkb 2
	.dbsym e Zero_Data _Zero_Data I
_tempL::
	.blkb 1
	.dbsym e tempL _tempL c
_tempH::
	.blkb 1
	.dbsym e tempH _tempH c

⌨️ 快捷键说明

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