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

📄 main.ls

📁 该程序是ST7MC驱动BLDC120
💻 LS
📖 第 1 页 / 共 2 页
字号:
 322                     ; 141     	   				if (timer_after_start != 0)		// motor stalled in starting stage(in 10 seconds) 
 324  0107 c60001        	ld	a,_timer_after_start+1
 325  010a 2603          	jrne	L6
 326  010c ce0000        	ld	x,_timer_after_start
 327  010f               L6:
 328  010f 27e9          	jreq	L74
 329                     ; 143     	   					stall_counter++;
 331  0111 c60000        	ld	a,_stall_counter
 332  0114 4c            	inc	a
 333  0115 c70000        	ld	_stall_counter,a
 334                     ; 144     	   					if (stall_counter < 0x03)   // motor stalling time is low than 3
 336  0118 a103          	cp	a,#3
 337  011a 2419          	jruge	L511
 338                     ; 146     	   						MTC_StopMotor();	    // prepare for starting again				
 340  011c cd0000        	call	_MTC_StopMotor
 342                     ; 147     	   						SetMotorStatus((u8)(GetMotorStatus() & (u8)(~MOTOR_STALLED)));
 344  011f cd0000        	call	_GetMotorStatus
 346  0122 a4ef          	and	a,#239
 347  0124 cd0000        	call	_SetMotorStatus
 349                     ; 148 								if ((u8)(GetMotorStatus() & FAULT_MSK) == 0) State = IDLE;												
 351  0127 cd0000        	call	_GetMotorStatus
 353  012a a5f0          	bcp	a,#240
 354  012c 26cc          	jrne	L74
 357  012e 4f            	clr	a
 358  012f c70002        	ld	L3_State,a
 359  0132 cc0029        	jra	L74
 360  0135               L511:
 361                     ; 152     	   						stall_counter = 0;			// prepare for stall counter
 363  0135 4f            	clr	a
 364  0136 c70000        	ld	_stall_counter,a
 365                     ; 153     	   						SetMotorStatus((u8)(GetMotorStatus() & (u8)(~MOTOR_STALLED)));
 367  0139 cd0000        	call	_GetMotorStatus
 369  013c a4ef          	and	a,#239
 370  013e cd0000        	call	_SetMotorStatus
 372                     ; 154     	   						SetMotorStatus((u8)(GetMotorStatus() | (u8)(START_UP_FAILED)));
 374  0141 cd0000        	call	_GetMotorStatus
 376  0144 aa40          	or	a,#64
 377  0146 cd0000        	call	_SetMotorStatus
 379  0149 cc0029        	jra	L74
 380  014c               L111:
 381                     ; 161     	    		 	if (timer_after_start == 0) stall_counter = 0;		    	    		 	    		   	    	    		   	                	       	    	   
 383  014c c60001        	ld	a,_timer_after_start+1
 384  014f 2608          	jrne	L321
 385  0151 ce0000        	ld	x,_timer_after_start
 386  0154 2603          	jrne	L321
 389  0156 c70000        	ld	_stall_counter,a
 390  0159               L321:
 391                     ; 163   			    	if (MotorStatus & AUTO_SWITCH) 
 393  0159 010015        	btjf	_MotorStatus,#0,L721
 394                     ; 165 						Change_Speed(); 			// acceleration rate = 1 Hz/0.2Sec												
 396  015c cd0000        	call	_Change_Speed
 398                     ; 167 						if (ValBit(Flag_MTC,SAMP_EVT))     // update PWM?
 400  015f c60000        	ld	a,_Flag_MTC
 401  0162 a502          	bcp	a,#2
 402  0164 270b          	jreq	L721
 403                     ; 171 							ClrBit(Flag_MTC,SAMP_EVT);
 405  0166 a4fd          	and	a,#253
 406  0168 c70000        	ld	_Flag_MTC,a
 407                     ; 178 				                Set_Target_Electrical_Frequency(Get_CurrentTargetSpeed());
 409  016b cd0000        	call	_Get_CurrentTargetSpeed
 411  016e cd0000        	call	_Set_Target_Electrical_Frequency
 413  0171               L721:
 414                     ; 201 					if (MotorCmd == STOP_CMD) State = BRAKE;
 416  0171 c60000        	ld	a,_MotorCmd
 417  0174 26d3          	jrne	L74
 420  0176 a604          	ld	a,#4
 421  0178 c70002        	ld	L3_State,a
 422  017b cc0029        	jra	L74
 423  017e               L31:
 424                     ; 204 			case BRAKE: 
 424                     ; 205      	    		if (active_brake(Brake_Duty,Brake_Time) == TRUE) State = STOP;
 426  017e 3f02          	clr	_active_brake$L+2
 427  0180 3f03          	clr	_active_brake$L+3
 428  0182 5f            	clr	x
 429  0183 cd0000        	call	_active_brake
 431  0186 a101          	cp	a,#1
 432  0188 26f1          	jrne	L74
 435  018a a603          	ld	a,#3
 436  018c c70002        	ld	L3_State,a
 437  018f cc0029        	jra	L74
 438  0192               L51:
 439                     ; 208 			case STOP:
 439                     ; 209                 	MTC_StopMotor();
 441  0192 cd0000        	call	_MTC_StopMotor
 443                     ; 210 					State = IDLE;
 445  0195 4f            	clr	a
 446  0196 c70002        	ld	L3_State,a
 447                     ; 211 					Set_RestartTimer(18000); // 3 Min delay 
 449  0199 a650          	ld	a,#80
 450  019b ae46          	ld	x,#70
 451  019d cd0000        	call	_Set_RestartTimer
 453                     ; 212 					break;
 455  01a0 cc0029        	jra	L74
 456  01a3               L12:
 457                     ; 216 			case FAULT:
 457                     ; 217 		        default:
 457                     ; 218 			        MotorStatus_Backup = MotorStatus;
 459  01a3 b600          	ld	a,_MotorStatus
 460  01a5 c70000        	ld	_MotorStatus_Backup,a
 461                     ; 219 			        MTC_StopMotor();			        
 463  01a8 cd0000        	call	_MTC_StopMotor
 465                     ; 220     				start_counter = 0;           // prepare for the start counter
 467  01ab 4f            	clr	a
 468  01ac c70001        	ld	_start_counter,a
 469                     ; 221 		    		stall_counter = 0;           // prepare for the stall counter		    	
 471  01af c70000        	ld	_stall_counter,a
 472                     ; 222 			        if ((Timer_RestartTimerBegin() == FALSE) && (MotorCmd != STOP_CMD)) 
 474  01b2 cd0000        	call	_Timer_RestartTimerBegin
 476  01b5 4d            	tnz	a
 477  01b6 260c          	jrne	L731
 479  01b8 c60000        	ld	a,_MotorCmd
 480  01bb 2707          	jreq	L731
 481                     ; 223 			        	Set_RestartTimer(18000); // 3 Min delay
 483  01bd a650          	ld	a,#80
 484  01bf ae46          	ld	x,#70
 485  01c1 cd0000        	call	_Set_RestartTimer
 487  01c4               L731:
 488                     ; 224 					if ((MotorStatus & FAULT_MSK) == 0) 
 490  01c4 b600          	ld	a,_MotorStatus
 491  01c6 a5f0          	bcp	a,#240
 492  01c8 2604          	jrne	L141
 493                     ; 226 						State = IDLE; 
 495  01ca 4f            	clr	a
 496  01cb c70002        	ld	L3_State,a
 497  01ce               L141:
 498                     ; 229 					MotorCmd = STOP_CMD;
 500  01ce 4f            	clr	a
 501  01cf c70000        	ld	_MotorCmd,a
 502                     ; 230 				break;
 504  01d2 cc0029        	jra	L74
 611                     	xdef	_main
 612                     	switch	.bss
 613  0000               _stall_counter:
 614  0000 00            	ds.b	1
 615                     	xdef	_stall_counter
 616  0001               _start_counter:
 617  0001 00            	ds.b	1
 618                     	xdef	_start_counter
 619                     	xdef	_KEY_CODE
 620  0002               L3_State:
 621  0002 00            	ds.b	1
 622                     	xref	_SPI_Init
 623                     	xref	_Chk_Timer_WDG_Elapsed
 624                     	xref	_WWD_Refresh
 625                     	xref	_WWD_Init
 626                     	xref	_ST7_IntPrioritySetUp
 627                     	xref	_Get_TargetSpeed
 628                     	xref	_Change_Speed
 629                     	xref	_Chk_Power_Motor_Status
 630                     	xref	_SCI_IsReceptionCompleted
 631                     	xref	_SCI_Send_Data
 632                     	xref	_SCI_Config
 633                     	xref	_MotorStatus_Backup
 634                     	xref	_Set_RestartTimer
 635                     	xref	_Get_CurrentTargetSpeed
 636                     	xref	_Timer_RestartTimerBegin
 637                     	xref	_Resert_SCIRX_Watchdog
 638                     	xref	_TIMA_Config
 639                     	xref	_PORTS_LedOn
 640                     	xref	_PORTS_Init
 641                     	xref	_Chk_Motor_Stalled
 642                     	xref	_SetMotorStatus
 643                     	xref	_GetMotorStatus
 644                     	xref	_active_brake
 645                     	xref	_Set_Target_Electrical_Frequency
 646                     	xref	_MTC_StopMotor
 647                     	xref	_MTC_StartMotor
 648                     	xref	_MTC_InitPeripheral
 649                     	xref.b	_MotorStatus
 650                     	xref	_timer_after_start
 651                     	xref	_Power_Motor_Status
 652                     	xref	_MotorCmd
 653                     	xref	_Flag_MTC
 673                     	xref.b	_active_brake$L
 674                     	end

⌨️ 快捷键说明

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