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

📄 ad.s

📁 ATmega128和ads7864实现ATP闭环控制
💻 S
📖 第 1 页 / 共 2 页
字号:
	andi R24,15
	andi R25,0
	mov R25,R24
	clr R24
	std y+5,R25
	std y+4,R24
	.dbline 162
; 	sstemp[2]=sstemp[2]|uctemp[0];
	ldd R2,y+8
	clr R3
	movw R4,R24
	or R4,R2
	or R5,R3
	std y+5,R5
	std y+4,R4
	.dbline 163
; 	sstemp[2]=sstemp[2]<<4;
	movw R2,R4
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	std y+5,R3
	std y+4,R2
	.dbline 165
; 	
; 	PORTD=PORTD|0x0C;
	in R24,0x12
	ori R24,12
	out 0x12,R24
	.dbline 166
; 	PORTD=PORTD&0xEF;	//A2A1A0:011	channel B1
	in R24,0x12
	andi R24,239
	out 0x12,R24
	.dbline 167
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 168
; 	NOP();
	nop
	.dbline 169
; 	uctemp[0]=PINC;		//first byte
	in R2,0x13
	std y+8,R2
	.dbline 170
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 171
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 172
; 	NOP();
	nop
	.dbline 173
; 	uctemp[1]=PINC;		//second byte
	in R2,0x13
	std y+9,R2
	.dbline 174
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 175
; 	sstemp[3]=(uctemp[1]&0x0F)<<8;
	mov R24,R2
	clr R25
	andi R24,15
	andi R25,0
	mov R25,R24
	clr R24
	std y+7,R25
	std y+6,R24
	.dbline 176
; 	sstemp[3]=sstemp[3]|uctemp[0];
	ldd R2,y+8
	clr R3
	movw R4,R24
	or R4,R2
	or R5,R3
	std y+7,R5
	std y+6,R4
	.dbline 177
; 	sstemp[3]=sstemp[3]<<4;
	movw R2,R4
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	std y+7,R3
	std y+6,R2
	.dbline 179
; 
; 	SETBIT(AD_CS_OUT, AD_CS);//unselect the ads7864
	lds R24,101
	ori R24,1
	sts 101,R24
	.dbline 181
; 
; 	pulOutBuff[0]=sstemp[0]+32768;
	ldd R24,y+0
	ldd R25,y+1
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R2,R24
	clr R4
	clr R5
	movw R30,R16
	std z+0,R2
	std z+1,R3
	std z+2,R4
	std z+3,R5
	.dbline 182
; 	pulOutBuff[1]=sstemp[1]+32768;
	ldd R24,y+2
	ldd R25,y+3
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R2,R24
	clr R4
	clr R5
	std z+4,R2
	std z+5,R3
	std z+6,R4
	std z+7,R5
	.dbline 183
; 	pulOutBuff[2]=sstemp[2]+32768;
	ldd R24,y+4
	ldd R25,y+5
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R2,R24
	clr R4
	clr R5
	movw R30,R16
	std z+8,R2
	std z+9,R3
	std z+10,R4
	std z+11,R5
	.dbline 184
; 	pulOutBuff[3]=sstemp[3]+32768;
	ldd R24,y+6
	ldd R25,y+7
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R2,R24
	clr R4
	clr R5
	movw R30,R16
	std z+12,R2
	std z+13,R3
	std z+14,R4
	std z+15,R5
	.dbline -2
L23:
	adiw R28,10
	.dbline 0 ; func end
	ret
	.dbsym l uctemp 8 A[2:2]c
	.dbsym l sstemp 0 A[8:4]S
	.dbsym r pulOutBuff 16 pl
	.dbend
	.dbfunc e usAD_GetData _usAD_GetData fV
;         uctemp -> y+8
;         sstemp -> y+0
;     pusOutBuff -> R16,R17
	.even
_usAD_GetData::
	sbiw R28,10
	.dbline -1
	.dbline 281
; 
; }
; 
; 
; /*
; void usAD_GetData(u16* pusOutBuff)
; {
; 	u8 uctemp[2];
; 	s16 sstemp[4];
; 	
; 	//sstemp[0]=0;
; 	//sstemp[1]=0;
; 	//sstemp[2]=0;
; 	//sstemp[3]=0;
; 
; 	
; 	//hold channel A and channel B
; 	PORTD=PORTD&0x9F;	//bring HoldA,HoldB low
; 	PORTD=PORTD|0xE0;	//bring HoldA,HoldB high
; 
; 	while(CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until first convertion is started
; 	while(0x00==CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until first convertion is finished
; 	while(CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until second convertion is started
; 	while(0x00==CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until second convertion is finished
; 	CLEARBIT(AD_CS_OUT, AD_CS);//select the ads7864
; 
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	
; 	PORTD=PORTD|0x0C;
; 	PORTD=PORTD&0xE3;	//A2A1A0:000	channel A0
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[0]=PINC;		//first byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[1]=PINC;		//second byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	sstemp[0]=(uctemp[1]&0x0F)<<8;
; 	sstemp[0]=sstemp[0]|uctemp[0];
; 	sstemp[0]=sstemp[0]<<4;
; 
; 	PORTD=PORTD|0x0C;
; 	PORTD=PORTD&0xE7;	//A2A1A0:001	channel A1
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[0]=PINC;		//first byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[1]=PINC;		//second byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	sstemp[1]=(uctemp[1]&0x0F)<<8;
; 	sstemp[1]=sstemp[1]|uctemp[0];
; 	sstemp[1]=sstemp[1]<<4;
; 
; 	
; 	PORTD=PORTD|0x0C;
; 	PORTD=PORTD&0xEB;	//A2A1A0:010	channel B0
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[0]=PINC;		//first byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[1]=PINC;		//second byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	sstemp[2]=(uctemp[1]&0x0F)<<8;
; 	sstemp[2]=sstemp[2]|uctemp[0];
; 	sstemp[2]=sstemp[2]<<4;
; 	
; 	PORTD=PORTD|0x0C;
; 	PORTD=PORTD&0xEF;	//A2A1A0:011	channel B1
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[0]=PINC;		//first byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	CLEARBIT(AD_RD_OUT, AD_RD);
; 	NOP();
; 	uctemp[1]=PINC;		//second byte
; 	SETBIT(AD_RD_OUT, AD_RD);
; 	sstemp[3]=(uctemp[1]&0x0F)<<8;
; 	sstemp[3]=sstemp[3]|uctemp[0];
; 	sstemp[3]=sstemp[3]<<4;
; 
; 	SETBIT(AD_CS_OUT, AD_CS);//unselect the ads7864
; 
; 	pusOutBuff[0]=sstemp[0]+32768;
; 	pusOutBuff[1]=sstemp[1]+32768;
; 	pusOutBuff[2]=sstemp[2]+32768;
; 	pusOutBuff[3]=sstemp[3]+32768;
; 
; }
; */
; 
; void usAD_GetData(u16* pusOutBuff)
; {
	.dbline 286
; 	u8 uctemp[2];
; 	s16 sstemp[4];
; 	
; 	//hold channel A and channel B
; 	PORTD=PORTD&0x9F;	//bring HoldA,HoldB low
	in R24,0x12
	andi R24,159
	out 0x12,R24
	.dbline 287
; 	PORTD=PORTD|0xE0;	//bring HoldA,HoldB high
	in R24,0x12
	ori R24,224
	out 0x12,R24
L63:
	.dbline 289
L64:
	.dbline 289
; 
; 	while(CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until first convertion is started
	sbic 0x10,0
	rjmp L63
L66:
	.dbline 290
L67:
	.dbline 290
; 	while(0x00==CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until first convertion is finished
	sbis 0x10,0
	rjmp L66
L69:
	.dbline 291
L70:
	.dbline 291
; 	while(CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until second convertion is started
	sbic 0x10,0
	rjmp L69
L72:
	.dbline 292
L73:
	.dbline 292
; 	while(0x00==CHECKBIT(AD_BUSY_IN, AD_BUSY));//wait until second convertion is finished
	sbis 0x10,0
	rjmp L72
	.dbline 293
; 	CLEARBIT(AD_CS_OUT, AD_CS);//select the ads7864
	lds R24,101
	andi R24,254
	sts 101,R24
	.dbline 295
; 
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 297
; 	
; 	PORTD=PORTD|0x0C;
	in R24,0x12
	ori R24,12
	out 0x12,R24
	.dbline 298
; 	PORTD=PORTD&0xE3;	//A2A1A0:000	channel A0
	in R24,0x12
	andi R24,227
	out 0x12,R24
	.dbline 299
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 300
; 	NOP();
	nop
	.dbline 301
; 	uctemp[0]=PINC;		//first byte
	in R2,0x13
	std y+8,R2
	.dbline 302
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 303
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 304
; 	NOP();
	nop
	.dbline 305
; 	uctemp[1]=PINC;		//second byte
	in R2,0x13
	std y+9,R2
	.dbline 306
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 307
; 	sstemp[2]=(uctemp[1]&0x0F)<<8;
	mov R24,R2
	clr R25
	andi R24,15
	andi R25,0
	mov R25,R24
	clr R24
	std y+5,R25
	std y+4,R24
	.dbline 308
; 	sstemp[2]=sstemp[2]|uctemp[0];
	ldd R2,y+8
	clr R3
	movw R4,R24
	or R4,R2
	or R5,R3
	std y+5,R5
	std y+4,R4
	.dbline 309
; 	sstemp[2]=sstemp[2]<<4;
	movw R2,R4
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	std y+5,R3
	std y+4,R2
	.dbline 311
; 
; 	PORTD=PORTD|0x0C;
	in R24,0x12
	ori R24,12
	out 0x12,R24
	.dbline 312
; 	PORTD=PORTD&0xE7;	//A2A1A0:001	channel A1
	in R24,0x12
	andi R24,231
	out 0x12,R24
	.dbline 313
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 314
; 	NOP();
	nop
	.dbline 315
; 	uctemp[0]=PINC;		//first byte
	in R2,0x13
	std y+8,R2
	.dbline 316
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 317
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 318
; 	NOP();
	nop
	.dbline 319
; 	uctemp[1]=PINC;		//second byte
	in R2,0x13
	std y+9,R2
	.dbline 320
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 321
; 	sstemp[3]=(uctemp[1]&0x0F)<<8;
	mov R24,R2
	clr R25
	andi R24,15
	andi R25,0
	mov R25,R24
	clr R24
	std y+7,R25
	std y+6,R24
	.dbline 322
; 	sstemp[3]=sstemp[3]|uctemp[0];
	ldd R2,y+8
	clr R3
	movw R4,R24
	or R4,R2
	or R5,R3
	std y+7,R5
	std y+6,R4
	.dbline 323
; 	sstemp[3]=sstemp[3]<<4;
	movw R2,R4
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	std y+7,R3
	std y+6,R2
	.dbline 326
; 
; 	
; 	PORTD=PORTD|0x0C;
	in R24,0x12
	ori R24,12
	out 0x12,R24
	.dbline 327
; 	PORTD=PORTD&0xEB;	//A2A1A0:010	channel B0
	in R24,0x12
	andi R24,235
	out 0x12,R24
	.dbline 328
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 329
; 	NOP();
	nop
	.dbline 330
; 	uctemp[0]=PINC;		//first byte
	in R2,0x13
	std y+8,R2
	.dbline 331
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 332
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 333
; 	NOP();
	nop
	.dbline 334
; 	uctemp[1]=PINC;		//second byte
	in R2,0x13
	std y+9,R2
	.dbline 335
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 336
; 	sstemp[0]=(uctemp[1]&0x0F)<<8;
	mov R24,R2
	clr R25
	andi R24,15
	andi R25,0
	mov R25,R24
	clr R24
	std y+1,R25
	std y+0,R24
	.dbline 337
; 	sstemp[0]=sstemp[0]|uctemp[0];
	ldd R2,y+8
	clr R3
	movw R4,R24
	or R4,R2
	or R5,R3
	std y+1,R5
	std y+0,R4
	.dbline 338
; 	sstemp[0]=sstemp[0]<<4;
	movw R2,R4
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	std y+1,R3
	std y+0,R2
	.dbline 340
; 	
; 	PORTD=PORTD|0x0C;
	in R24,0x12
	ori R24,12
	out 0x12,R24
	.dbline 341
; 	PORTD=PORTD&0xEF;	//A2A1A0:011	channel B1
	in R24,0x12
	andi R24,239
	out 0x12,R24
	.dbline 342
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 343
; 	NOP();
	nop
	.dbline 344
; 	uctemp[0]=PINC;		//first byte
	in R2,0x13
	std y+8,R2
	.dbline 345
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 346
; 	CLEARBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 347
; 	NOP();
	nop
	.dbline 348
; 	uctemp[1]=PINC;		//second byte
	in R2,0x13
	std y+9,R2
	.dbline 349
; 	SETBIT(AD_RD_OUT, AD_RD);
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 350
; 	sstemp[1]=(uctemp[1]&0x0F)<<8;
	mov R24,R2
	clr R25
	andi R24,15
	andi R25,0
	mov R25,R24
	clr R24
	std y+3,R25
	std y+2,R24
	.dbline 351
; 	sstemp[1]=sstemp[1]|uctemp[0];
	ldd R2,y+8
	clr R3
	movw R4,R24
	or R4,R2
	or R5,R3
	std y+3,R5
	std y+2,R4
	.dbline 352
; 	sstemp[1]=sstemp[1]<<4;
	movw R2,R4
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	std y+3,R3
	std y+2,R2
	.dbline 354
; 
; 	SETBIT(AD_CS_OUT, AD_CS);//unselect the ads7864
	lds R24,101
	ori R24,1
	sts 101,R24
	.dbline 356
; 
; 	pusOutBuff[0]=sstemp[0]+32768;
	ldd R24,y+0
	ldd R25,y+1
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R30,R16
	std z+1,R25
	std z+0,R24
	.dbline 357
; 	pusOutBuff[1]=sstemp[1]+32768;
	movw R24,R2
	subi R24,0  ; offset = 32768
	sbci R25,128
	std z+3,R25
	std z+2,R24
	.dbline 358
; 	pusOutBuff[2]=sstemp[2]+32768;
	ldd R24,y+4
	ldd R25,y+5
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R30,R16
	std z+5,R25
	std z+4,R24
	.dbline 359
; 	pusOutBuff[3]=sstemp[3]+32768;
	ldd R24,y+6
	ldd R25,y+7
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R30,R16
	std z+7,R25
	std z+6,R24
	.dbline -2
L62:
	adiw R28,10
	.dbline 0 ; func end
	ret
	.dbsym l uctemp 8 A[2:2]c
	.dbsym l sstemp 0 A[8:4]S
	.dbsym r pusOutBuff 16 ps
	.dbend

⌨️ 快捷键说明

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