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

📄 ex_support.s

📁 一个直流电机的闭环控制源代码程序
💻 S
📖 第 1 页 / 共 2 页
字号:
	sts _g_bIfMarkDistance,R2
	.dbline 191
;             s_bIfSendSuccess = TRUE;
	ldi R24,1
	sts L7,R24
	.dbline 192
;         }
	rjmp L17
L16:
	.dbline 194
;         else
;         {
	.dbline 195
;             if (!g_bIfMarkDistance)
	lds R2,_g_bIfMarkDistance
	tst R2
	breq X26
	rjmp L21
X26:
X9:
	.dbline 196
;             {
	.dbline 197
;                 if (g_cSpeed < 0)
	lds R24,_g_cSpeed
	cpi R24,0
	brge L23
X10:
	.dbline 198
;                 {
	.dbline 199
;                     g_dGoDistance = g_dNowMotorPosition - (int32)((float)g_wDistance * (float)MM_K);
	ldi R16,<L25
	ldi R17,>L25
	rcall lpm32
	movw R2,R16
	movw R4,R18
	lds R16,_g_wDistance
	lds R17,_g_wDistance+1
	rcall uint2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R2
	movw R18,R4
	rcall fpmule2
	rcall fpint
	lds R4,_g_dNowMotorPosition+2
	lds R5,_g_dNowMotorPosition+2+1
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	sts _g_dGoDistance+1,R3
	sts _g_dGoDistance,R2
	sts _g_dGoDistance+2+1,R5
	sts _g_dGoDistance+2,R4
	.dbline 200
;                 }
	rjmp L24
L23:
	.dbline 202
;                 else
;                 {
	.dbline 203
;                     g_dGoDistance = g_dNowMotorPosition + (int32)((float)g_wDistance * (float)MM_K);
	ldi R16,<L25
	ldi R17,>L25
	rcall lpm32
	movw R2,R16
	movw R4,R18
	lds R16,_g_wDistance
	lds R17,_g_wDistance+1
	rcall uint2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R2
	movw R18,R4
	rcall fpmule2
	rcall fpint
	lds R4,_g_dNowMotorPosition+2
	lds R5,_g_dNowMotorPosition+2+1
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	add R2,R16
	adc R3,R17
	adc R4,R18
	adc R5,R19
	sts _g_dGoDistance+1,R3
	sts _g_dGoDistance,R2
	sts _g_dGoDistance+2+1,R5
	sts _g_dGoDistance+2,R4
	.dbline 204
;                 }
L24:
	.dbline 206
; 
;                 g_bIfMarkDistance = TRUE;
	ldi R24,1
	sts _g_bIfMarkDistance,R24
	.dbline 207
;             }
	rjmp L22
L21:
	.dbline 209
;             else
;             {
	.dbline 210
;                 nTempDistance = g_dGoDistance - g_dNowMotorPosition;
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	lds R12,_g_dGoDistance
	lds R13,_g_dGoDistance+1
	sub R12,R2
	sbc R13,R3
	.dbline 212
; 
;                 if (nTempDistance < 0)
	movw R24,R12
	cpi R24,0
	ldi R30,0
	cpc R25,R30
	brlt X27
	rjmp L26
X27:
X11:
	.dbline 213
;                 {
	.dbline 215
;                     
;                     if (g_cSpeed < 0)
	lds R24,_g_cSpeed
	cpi R24,0
	brlt X28
	rjmp L27
X28:
X12:
	.dbline 216
;                     {
	.dbline 218
;                         //合法速度
;                         if (ABS(nTempDistance) <= ABS(g_cSpeed))
	movw R24,R12
	cpi R24,0
	ldi R30,0
	cpc R25,R30
	brge L32
X13:
	com R24
	com R25
	subi R24,0xFF
	sbci R25,0xFF
	movw R10,R24
	rjmp L33
L32:
	movw R10,R12
L33:
	lds R24,_g_cSpeed
	cpi R24,0
	brge L34
X14:
	clr R25
	sbrc R24,7
	com R25
	com R24
	com R25
	subi R24,0xFF
	sbci R25,0xFF
	movw R14,R24
	rjmp L35
L34:
	lds R14,_g_cSpeed
	clr R15
	sbrc R14,7
	com R15
L35:
	cp R14,R10
	cpc R15,R11
	brlt L30
X15:
	.dbline 219
;                         {
	.dbline 221
;                             //完成动作
;                             g_dAimMotorPosition = g_dGoDistance;
	lds R4,_g_dGoDistance+2
	lds R5,_g_dGoDistance+2+1
	lds R2,_g_dGoDistance
	lds R3,_g_dGoDistance+1
	sts _g_dAimMotorPosition+1,R3
	sts _g_dAimMotorPosition,R2
	sts _g_dAimMotorPosition+2+1,R5
	sts _g_dAimMotorPosition+2,R4
	.dbline 223
;                             //需要发送完成信号
;                             s_bIfSendSuccess = FALSE;
	clr R2
	sts L7,R2
	.dbline 224
;                         }
	rjmp L27
L30:
	.dbline 226
;                         else
;                         {
	.dbline 227
;                             g_dAimMotorPosition += g_cSpeed;
	lds R2,_g_cSpeed
	clr R3
	sbrc R2,7
	com R3
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	lds R8,_g_dAimMotorPosition+2
	lds R9,_g_dAimMotorPosition+2+1
	lds R6,_g_dAimMotorPosition
	lds R7,_g_dAimMotorPosition+1
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	sts _g_dAimMotorPosition+1,R7
	sts _g_dAimMotorPosition,R6
	sts _g_dAimMotorPosition+2+1,R9
	sts _g_dAimMotorPosition+2,R8
	.dbline 228
;                         }
	.dbline 229
;                     }
	.dbline 238
;                     /*
;                     else
;                     {
;                         //非法速度
;                         //g_dGoDistance = 0;
;                         //g_bIfMarkDistance = FALSE;
;                     }
;                     */
;                 }
	rjmp L27
L26:
	.dbline 239
;                 else if (nTempDistance > 0)
	clr R2
	clr R3
	cp R2,R12
	cpc R3,R13
	brlt X29
	rjmp L36
X29:
X16:
	.dbline 240
;                 {
	.dbline 242
;                     
;                     if (g_cSpeed <= 0)
	lds R3,_g_cSpeed
	cp R2,R3
	brlt L38
X17:
	.dbline 243
;                     {
	.dbline 248
;                         //非法数据
;                         //g_dGoDistance = 0;
;                         //g_bIfMarkDistance = FALSE;
;                         
;                     }
	rjmp L39
L38:
	.dbline 249
;                     else if (g_cSpeed > 0)
	clr R2
	lds R3,_g_cSpeed
	cp R2,R3
	brlt X30
	rjmp L40
X30:
X18:
	.dbline 250
;                     {
	.dbline 252
;                         //合法速度
;                         if (ABS(nTempDistance) <= ABS(g_cSpeed))
	movw R24,R12
	cpi R24,0
	ldi R30,0
	cpc R25,R30
	brge L44
X19:
	com R24
	com R25
	subi R24,0xFF
	sbci R25,0xFF
	movw R10,R24
	rjmp L45
L44:
	movw R10,R12
L45:
	lds R24,_g_cSpeed
	cpi R24,0
	brge L46
X20:
	clr R25
	sbrc R24,7
	com R25
	com R24
	com R25
	subi R24,0xFF
	sbci R25,0xFF
	movw R12,R24
	rjmp L47
L46:
	lds R12,_g_cSpeed
	clr R13
	sbrc R12,7
	com R13
L47:
	cp R12,R10
	cpc R13,R11
	brlt L42
X21:
	.dbline 253
;                         {
	.dbline 255
;                             //完成动作
;                             g_dAimMotorPosition = g_dGoDistance;
	lds R4,_g_dGoDistance+2
	lds R5,_g_dGoDistance+2+1
	lds R2,_g_dGoDistance
	lds R3,_g_dGoDistance+1
	sts _g_dAimMotorPosition+1,R3
	sts _g_dAimMotorPosition,R2
	sts _g_dAimMotorPosition+2+1,R5
	sts _g_dAimMotorPosition+2,R4
	.dbline 257
;                             //需要发送完成信号
;                             s_bIfSendSuccess = FALSE;
	clr R2
	sts L7,R2
	.dbline 258
;                         }
	rjmp L43
L42:
	.dbline 260
;                         else
;                         {
	.dbline 261
;                             g_dAimMotorPosition += g_cSpeed;
	lds R2,_g_cSpeed
	clr R3
	sbrc R2,7
	com R3
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	lds R8,_g_dAimMotorPosition+2
	lds R9,_g_dAimMotorPosition+2+1
	lds R6,_g_dAimMotorPosition
	lds R7,_g_dAimMotorPosition+1
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	sts _g_dAimMotorPosition+1,R7
	sts _g_dAimMotorPosition,R6
	sts _g_dAimMotorPosition+2+1,R9
	sts _g_dAimMotorPosition+2,R8
	.dbline 262
;                         }
L43:
	.dbline 263
;                     }
L40:
L39:
	.dbline 264
;                 }
L36:
L27:
	.dbline 266
;                 
;                 if (!s_bIfSendSuccess)
	lds R2,L7
	tst R2
	brne L48
X22:
	.dbline 267
;                 {
	.dbline 268
;                     s_bIfSendSuccess = TRUE;
	ldi R24,1
	sts L7,R24
	.dbline 269
;                     SERIAL_OUT(0xAC);
	ldi R16,172
	rcall _UARTaddDataToTxBuff
	.dbline 269
	.dbline 270
;                 }
L48:
	.dbline 271
;             }
L22:
	.dbline 272
;         }
L17:
	.dbline 273
;     }
L14:
	.dbline -2
L6:
	.dbline 0 ; func end
	rjmp pop_xgsetF0FC
	.dbsym r nTempDistance1 12 I
	.dbend
	.area lit(rom, con, rel)
L25:
	.word 0x4d8e,0x41a0
;     
;     
; }

⌨️ 快捷键说明

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