📄 mc_bldc_drive.ls
字号:
1 ; C Compiler for STM8 (COSMIC Software)
2 ; Parser V4.9.10 - 10 Feb 2011
3 ; Generator (Limited) V4.3.6 - 15 Feb 2011
4 ; Optimizer V4.3.5 - 15 Feb 2011
19 .const: section .text
20 0000 L5_hArrPwmVal:
21 0000 0378 dc.w 888
22 0002 L7_CurrentLimit:
23 0002 0708 dc.w 1800
24 bsct
25 0000 L71_DriveState:
26 0000 00 dc.b 0
27 0001 L32_bValidatedMeasuredSpeed:
28 0001 00 dc.b 0
87 ; 84 u16 GetSpeed_01HZ(void)
87 ; 85 {
89 switch .text
90 0000 _GetSpeed_01HZ:
92 0000000c OFST: set 12
95 ; 89 if (*pcounter_reg == 0)
97 0000 be04 ldw x,L31_pcounter_reg
98 0002 520c subw sp,#12
99 0004 e601 ld a,(1,x)
100 0006 fa or a,(x)
101 0007 2603 jrne L16
102 ; 90 return 0;
104 0009 5f clrw x
106 000a 202a jra L6
107 000c L16:
108 ; 91 hTemp = PWM_FREQUENCY;
110 ; 92 wTemp = (u32)(hTemp) * 10;
112 000c aebf20 ldw x,#48928
113 000f 1f0b ldw (OFST-1,sp),x
114 0011 ae0002 ldw x,#2
115 0014 1f09 ldw (OFST-3,sp),x
116 ; 93 wTemp /= (*pcounter_reg);
118 0016 be04 ldw x,L31_pcounter_reg
119 0018 fe ldw x,(x)
120 0019 cd0000 call c_uitolx
122 001c 96 ldw x,sp
123 001d 5c incw x
124 001e cd0000 call c_rtol
126 0021 96 ldw x,sp
127 0022 1c0009 addw x,#OFST-3
128 0025 cd0000 call c_ltor
130 0028 96 ldw x,sp
131 0029 5c incw x
132 002a cd0000 call c_ludv
134 002d 96 ldw x,sp
135 002e 1c0009 addw x,#OFST-3
136 0031 cd0000 call c_rtol
138 ; 94 speedHz10 = (u16)(wTemp);
140 0034 1e0b ldw x,(OFST-1,sp)
141 ; 95 return speedHz10;
144 0036 L6:
146 0036 5b0c addw sp,#12
147 0038 81 ret
853 ; 98 void driveInit(pvdev_device_t pdevice)
853 ; 99 {
854 switch .text
855 0039 _driveInit:
857 0039 89 pushw x
858 003a 89 pushw x
859 00000002 OFST: set 2
862 ; 102 dev_driveInit(pdevice);
864 003b cd0000 call _dev_driveInit
866 ; 104 pBLDC_Struct = Get_BLDC_Struct();
868 003e cd0000 call _Get_BLDC_Struct
870 0041 1f01 ldw (OFST-1,sp),x
871 ; 105 g_pMotorVar = pBLDC_Struct->pBLDC_Var;
873 0043 fe ldw x,(x)
874 0044 bf0c ldw L3_g_pMotorVar,x
875 ; 106 bHztoRPM = (u8)(60 / pBLDC_Struct->pBLDC_Const->bMotor_Pole_Pairs);
877 0046 1601 ldw y,(OFST-1,sp)
878 0048 90ee02 ldw y,(2,y)
879 004b ae003c ldw x,#60
880 004e 90f6 ld a,(y)
881 0050 905f clrw y
882 0052 9097 ld yl,a
883 0054 cd0000 call c_idiv
885 0057 9f ld a,xl
886 0058 b70b ld _bHztoRPM,a
887 ; 107 g_pPID_Speed = pBLDC_Struct->pBLDC_Const->pPID_Speed;
889 005a 1e01 ldw x,(OFST-1,sp)
890 005c ee02 ldw x,(2,x)
891 005e ee06 ldw x,(6,x)
892 0060 bf09 ldw _g_pPID_Speed,x
893 ; 108 bSpeed_PID_sampling_time = pBLDC_Struct->pBLDC_Const->bSpeed_PID_sampling_time;
895 0062 1e01 ldw x,(OFST-1,sp)
896 0064 ee02 ldw x,(2,x)
897 0066 e605 ld a,(5,x)
898 0068 b708 ld _bSpeed_PID_sampling_time,a
899 ; 110 g_pdevice = pdevice;
901 006a 1e03 ldw x,(OFST+1,sp)
902 006c bf06 ldw L11_g_pdevice,x
903 ; 116 pcounter_reg = &(pdevice->regs.r16[VDEV_REG16_HALL_COUNTS]);
905 006e ee02 ldw x,(2,x)
906 0070 1c0002 addw x,#2
907 0073 bf04 ldw L31_pcounter_reg,x
908 ; 119 pDutyCycleCounts_reg = &(pdevice->regs.r16[VDEV_REG16_BLDC_DUTY_CYCLE_COUNTS]);
910 0075 1e03 ldw x,(OFST+1,sp)
911 0077 ee02 ldw x,(2,x)
912 0079 1c0008 addw x,#8
913 007c bf02 ldw L51_pDutyCycleCounts_reg,x
914 ; 121 vtimer_SetTimer(BLDC_CONTROL_TIMER,bSpeed_PID_sampling_time,&BLDC_Drive);
916 007e ae00d5 ldw x,#_BLDC_Drive
917 0081 89 pushw x
918 0082 5f clrw x
919 0083 97 ld xl,a
920 0084 89 pushw x
921 0085 a604 ld a,#4
922 0087 cd0000 call _vtimer_SetTimer
924 008a 5b08 addw sp,#8
925 ; 122 }
928 008c 81 ret
953 ; 124 void driveIdle(void)
953 ; 125 {
954 switch .text
955 008d _driveIdle:
959 ; 126 DriveState = DRIVE_IDLE;
961 008d 35010000 mov L71_DriveState,#1
962 ; 127 dev_driveIdle();
965 ; 128 }
968 0091 cc0000 jp _dev_driveIdle
1025 ; 130 MC_FuncRetVal_t driveStartUpInit(void)
1025 ; 131 {
1026 switch .text
1027 0094 _driveStartUpInit:
1031 ; 132 DriveState = DRIVE_STARTINIT;
1033 0094 35020000 mov L71_DriveState,#2
1034 ; 133 bValidatedMeasuredSpeed = 0;
1036 0098 3f01 clr L32_bValidatedMeasuredSpeed
1037 ; 135 bHallError = 0;
1039 009a 3f00 clr _bHallError
1040 ; 137 DriveStatus = FUNCTION_RUNNING;
1042 009c 3f01 clr L12_DriveStatus
1043 ; 140 g_pPID_Speed->pPID_Var->wIntegral = 0;
1045 009e 92ce09 ldw x,[_g_pPID_Speed.w]
1046 00a1 4f clr a
1047 00a2 e709 ld (9,x),a
1048 00a4 e708 ld (8,x),a
1049 00a6 e707 ld (7,x),a
1050 00a8 e706 ld (6,x),a
1051 ; 143 return dev_driveStartUpInit();
1056 00aa cc0000 jp _dev_driveStartUpInit
1082 ; 146 MC_FuncRetVal_t driveStartUp(void)
1082 ; 147 {
1083 switch .text
1084 00ad _driveStartUp:
1088 ; 148 DriveState = DRIVE_START;
1090 00ad 35030000 mov L71_DriveState,#3
1091 ; 149 return dev_driveStartUp();
1096 00b1 cc0000 jp _dev_driveStartUp
1123 ; 152 MC_FuncRetVal_t driveRun(void)
1123 ; 153 {
1124 switch .text
1125 00b4 _driveRun:
1129 ; 154 DriveState = DRIVE_RUN;
1131 00b4 35040000 mov L71_DriveState,#4
1132 ; 156 if (DriveStatus == FUNCTION_ERROR)
1134 00b8 b601 ld a,L12_DriveStatus
1135 00ba a102 cp a,#2
1136 00bc 2603 jrne L145
1137 ; 158 return FUNCTION_ERROR;
1139 00be a602 ld a,#2
1142 00c0 81 ret
1143 00c1 L145:
1144 ; 162 return dev_driveRun();
1149 00c1 cc0000 jp _dev_driveRun
1175 ; 166 MC_FuncRetVal_t driveStop(void)
1175 ; 167 {
1176 switch .text
1177 00c4 _driveStop:
1181 ; 168 DriveState = DRIVE_STOP;
1183 00c4 35050000 mov L71_DriveState,#5
1184 ; 169 return dev_driveStop();
1189 00c8 cc0000 jp _dev_driveStop
1215 ; 172 MC_FuncRetVal_t driveWait(void)
1215 ; 173 {
1216 switch .text
1217 00cb _driveWait:
1221 ; 174 DriveState = DRIVE_WAIT;
1223 00cb 35060000 mov L71_DriveState,#6
1224 ; 175 return dev_driveWait();
1229 00cf cc0000 jp _dev_driveWait
1253 ; 178 MC_FuncRetVal_t driveFault(void)
1253 ; 179 {
1254 switch .text
1255 00d2 _driveFault:
1259 ; 180 return FUNCTION_ENDED;
1261 00d2 a601 ld a,#1
1264 00d4 81 ret
1338 switch .const
1339 0004 L06:
1340 0004 00000064 dc.l 100
1341 ; 183 void BLDC_Drive(void)
1341 ; 184 {
1342 switch .text
1343 00d5 _BLDC_Drive:
1345 00d5 5204 subw sp,#4
1346 00000004 OFST: set 4
1349 ; 192 vtimer_SetTimer(BLDC_CONTROL_TIMER,bSpeed_PID_sampling_time,&BLDC_Drive);
1351 00d7 ae00d5 ldw x,#_BLDC_Drive
1352 00da 89 pushw x
1353 00db b608 ld a,_bSpeed_PID_sampling_time
1354 00dd 5f clrw x
1355 00de 97 ld xl,a
1356 00df 89 pushw x
1357 00e0 a604 ld a,#4
1358 00e2 cd0000 call _vtimer_SetTimer
1360 00e5 5b04 addw sp,#4
1361 ; 195 hSpeed_01HZ = GetSpeed_01HZ();
1363 00e7 cd0000 call _GetSpeed_01HZ
1365 ; 198 if (hSpeed_01HZ > HALL_MAX_SPEED_01HZ)
1367 00ea a305dd cpw x,#1501
1368 00ed 2503 jrult L726
1369 ; 200 hSpeed_01HZ = HALL_MAX_SPEED_01HZ;
1371 00ef ae05dc ldw x,#1500
1372 00f2 L726:
1373 00f2 1f03 ldw (OFST-1,sp),x
1374 ; 203 if ((hSpeed_01HZ < HALL_MIN_SPEED_01HZ) && (bValidatedMeasuredSpeed == 1))
1376 00f4 a300c8 cpw x,#200
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -