📄 bldc_basic.cod
字号:
LX51 LINKER/LOCATER V3.65b 10/12/2005 16:46:10 PAGE 1
ASSEMBLER CODE PACKING OF MODULE: BLDC_basic (MAIN)
00006B 213F AJMP 0100013FH
----- FUNCTION MAIN_vInit (BEGIN) -----
FILE: 'MAIN.C'
131: void MAIN_vInit(void)
132: {
133: // USER CODE BEGIN (MAIN_Init,2)
134:
135: // USER CODE END
136:
137: /// -----------------------------------------------------------------------
138: /// Configuration of the System Clock:
139: /// -----------------------------------------------------------------------
140: /// - On Chip Osc is Selected
141: /// - PLL Mode, NDIV = 2
142: /// - input frequency is 10 MHz
143:
144:
145:
146: /// *********************************************************************************
147: /// Note : All peripheral related IO configurations are done in the
148: /// respective peripheral modules (alternate functions selection)
149: /// *********************************************************************************
150:
151:
152: /// Initialization of module 'Capture / Compare Unit 6 (CCU6)'
153: CC6_vInit();
000087 11C1 ACALL CC6_vInit
154:
155: // Interrupt Priority
156:
157: IP = 0x00; // load Interrupt Priority Register
000089 E4 CLR A
00008A F5B8 MOV IP,A
158: IPH = 0x00; // load Interrupt Priority High Register
00008C F5B9 MOV IPH,A
159: IP1 = 0x00; // load Interrupt Priority 1 Register
00008E F5F8 MOV IP1,A
160: IPH1 = 0x00; // load Interrupt Priority 1 High Register
000090 F5F9 MOV IPH1,A
161:
162:
163: // USER CODE BEGIN (MAIN_Init,3)
164:
165: // USER CODE END
166:
167: // globally enable interrupts
168: EA = 1;
000092 D2AF SETB EA
169:
170: } // End of function MAIN_vInit
000094 22 RET
----- FUNCTION MAIN_vInit (END) -------
----- FUNCTION main (BEGIN) -----
FILE: 'MAIN.C'
194: void main(void)
195: {
196: // USER CODE BEGIN (MAIN_Main,2)
197:
LX51 LINKER/LOCATER V3.65b 10/12/2005 16:46:10 PAGE 2
198: unsigned char i;
199: // USER CODE END
200:
201: MAIN_vInit();
000095 1187 ACALL MAIN_vInit
202:
203: // USER CODE BEGIN (MAIN_Main,3)
204: #define MCM_transfer 0x80 //manual transfer from shadow registers
205:
206: i = (P2_DATA & 0x7); //read in the current hall state
000097 E5A0 MOV A,P2_DATA
000099 5407 ANL A,#07H
00009B FF MOV R7,A
;---- Variable 'i' assigned to Register 'R7' ----
207:
208: CCU6_MCMOUTSH = HallPatt[i] | MCM_transfer; //program the curr, exp hall states.
00009C 900079 MOV DPTR,#HallPatt
00009F 93 MOVC A,@A+DPTR
0000A0 FE MOV R6,A
0000A1 4480 ORL A,#080H
0000A3 F59F MOV CCU6_MCMOUTSH,A
209: CCU6_MCMOUTSL = OutputPatt[i] | MCM_transfer; //program the output pattern to the CCU port.
0000A5 EF MOV A,R7
0000A6 900080 MOV DPTR,#OutputPatt
0000A9 93 MOVC A,@A+DPTR
0000AA 4480 ORL A,#080H
0000AC F59E MOV CCU6_MCMOUTSL,A
210:
211: i=HallPatt[i]& 0x07; //get expected hall state
0000AE EE MOV A,R6
0000AF 5407 ANL A,#07H
0000B1 FF MOV R7,A
212:
213: CCU6_MCMOUTSH = HallPatt[i]; //program shadow registers with next state values
0000B2 900079 MOV DPTR,#HallPatt
0000B5 93 MOVC A,@A+DPTR
0000B6 F59F MOV CCU6_MCMOUTSH,A
214: CCU6_MCMOUTSL = OutputPatt[i]; //the shadow transfer will be automatic
0000B8 EF MOV A,R7
0000B9 900080 MOV DPTR,#OutputPatt
0000BC 93 MOVC A,@A+DPTR
0000BD F59E MOV CCU6_MCMOUTSL,A
0000BF ?C0002?MAIN:
215:
216: // USER CODE END
217:
218: while(1)
219: {
220:
221: // USER CODE BEGIN (MAIN_Main,4)
222:
223: // USER CODE END
224:
225: }
0000BF 80FE SJMP ?C0002?MAIN
----- FUNCTION main (END) -------
----- FUNCTION CC6_vInit (BEGIN) -----
FILE: 'CC6.C'
122: void CC6_vInit(void)
123: {
124: // USER CODE BEGIN (Init,2)
125:
126: // USER CODE END
LX51 LINKER/LOCATER V3.65b 10/12/2005 16:46:10 PAGE 3
127:
128: SFR_PAGE(_cc1, noSST); // switch to page 1
0000C1 75A301 MOV CCU6_PAGE,#01H
129:
130: /// -----------------------------------------------------------------------
131: /// Configuration of Timer Control Register
132: /// -----------------------------------------------------------------------
133:
134: CCU6_TCTR0L = 0x07; // load CCU6 timer control register 0 low
0000C4 75A607 MOV CCU6_TCTR0L,#07H
135: CCU6_TCTR0H = 0x00; // load CCU6 timer control register 0 high
0000C7 E4 CLR A
0000C8 F5A7 MOV CCU6_TCTR0H,A
136:
137: /// -----------------------------------------------------------------------
138: /// Configuration of CCU6 Timer 12:
139: /// -----------------------------------------------------------------------
140: /// - prescaler factor is 128
141: /// - timer 12 run bit is set
142: /// - single shot mode is disabled
143: /// - timer 12 works in edge aligned mode
144: /// - interrupt on period match is disabled
145: /// - interrupt on one match is disabled
146:
147: CCU6_T12PRL = 0xFF; // load CCU6 T12 period register low
0000CA 759CFF MOV CCU6_T12PRL,#0FFH
148: CCU6_T12PRH = 0xFF; // load CCU6 T12 period register lhigh
0000CD 759DFF MOV CCU6_T12PRH,#0FFH
149:
150: /// -----------------------------------------------------------------------
151: /// Configuration of CCU6 Timer 13:
152: /// -----------------------------------------------------------------------
153: /// - prescaler factor is 1
154: /// - timer 13 run bit is reset
155: /// - trigger control is disabled
156: /// - single shot mode is disabled
157: /// - interrupt on period match is disabled
158: /// - interrupt on compare match is disabled
159:
160: CCU6_T13PRL = 0x01; // load CCU6 T13 period register low
0000D0 759E01 MOV CCU6_T13PRL,#01H
161: CCU6_T13PRH = 0x00; // load CCU6 T13 period register high
0000D3 F59F MOV CCU6_T13PRH,A
162:
163: /// -----------------------------------------------------------------------
164: /// Configuration of Dead-Time Control Register for Timer T12
165: /// -----------------------------------------------------------------------
166:
167: CCU6_T12DTCL = 0x08; // load CCU6 dead time control register low
0000D5 75A408 MOV CCU6_T12DTCL,#08H
168: // for timer T12
169:
170: CCU6_T12DTCH = 0x01; // load CCU6 dead time control register high
0000D8 75A501 MOV CCU6_T12DTCH,#01H
171: // for timer T12
172:
173: SFR_PAGE(_cc0, noSST); // switch to page 0
0000DB F5A3 MOV CCU6_PAGE,A
174:
175: /// -----------------------------------------------------------------------
176: /// Configuration of CCU6 Channel 0:
177: /// -----------------------------------------------------------------------
178: /// - hall sensor mode is selected
179: /// - T13 modulation for output CC60 is disabled
180: /// - the output CC60 is set to the passive state
LX51 LINKER/LOCATER V3.65b 10/12/2005 16:46:10 PAGE 4
181: /// - the trap functionality of the pin CC60 is disabled
182: /// - the passive level of the output CC60 is '0'
183: /// - T13 modulation for output COUT60 is disabled
184: /// - the output COUT60 is set to the passive state
185: /// - the trap functionality of the pin COUT60 is disabled
186: /// - the passive level of the output COUT60 is '0'
187: /// - dead time generation is enabled
188:
189: /// - generation interrupt on flag ICC60R is disabled
190: /// - generation interrupt on flag ICC60F is disabled
191:
192: CCU6_CC60SRL = 0x00; // load CCU6 capture/compare shadow register
0000DD F5FA MOV CCU6_CC60SRL,A
193: // low for channel 0
194: CCU6_CC60SRH = 0x00; // load CCU6 capture/compare shadow register
0000DF F5FB MOV CCU6_CC60SRH,A
195: // high for channel 0
196:
197:
198: /// -----------------------------------------------------------------------
199: /// Configuration of CCU6 Channel 1:
200: /// -----------------------------------------------------------------------
201: /// - hall sensor mode is selected
202: /// - T13 modulation for output CC61 is disabled
203: /// - the output CC61 is set to the passive state
204: /// - the trap functionality of the pin CC61 is disabled
205: /// - the passive level of the output CC61 is '0'
206: /// - T13 modulation for output COUT61 is disabled
207: /// - the output COUT61 is set to the passive state
208: /// - the trap functionality of the pin COUT61 is disabled
209: /// - the passive level of the output COUT61 is '0'
210: /// - dead time generation is disabled
211:
212: /// - generation interrupt on flag ICC61R is disabled
213: /// - generation interrupt on flag ICC61F is disabled
214:
215: CCU6_CC61SRL = 0x00; // load CCU6 capture/compare shadow register
0000E1 F5FC MOV CCU6_CC61SRL,A
216: // low for channel 1
217: CCU6_CC61SRH = 0x00; // load CCU6 capture/compare shadow register
0000E3 F5FD MOV CCU6_CC61SRH,A
218: // high for channel 1
219:
220:
221: /// -----------------------------------------------------------------------
222: /// Configuration of CCU6 Channel 2:
223: /// -----------------------------------------------------------------------
224: /// - hall sensor mode is selected
225: /// - T13 modulation for output CC62 is disabled
226: /// - the output CC62 is set to the passive state
227: /// - the trap functionality of the pin CC62 is disabled
228: /// - the passive level of the output CC62 is '0'
229: /// - T13 modulation for output COUT62 is disabled
230: /// - the output COUT62 is set to the passive state
231: /// - the trap functionality of the pin COUT62 is disabled
232: /// - the passive level of the output COUT62 is '0'
233: /// - dead time generation is disabled
234:
235: /// - generation interrupt on flag ICC62R is disabled
236: /// - generation interrupt on flag ICC62F is disabled
237:
238: CCU6_CC62SRL = 0x00; // load CCU6 capture/compare shadow register
0000E5 F5FE MOV CCU6_CC62SRL,A
239: // low for channel 2
240: CCU6_CC62SRH = 0x00; // load CCU6 capture/compare shadow register
LX51 LINKER/LOCATER V3.65b 10/12/2005 16:46:10 PAGE 5
0000E7 F5FF MOV CCU6_CC62SRH,A
241: // high for channel 2
242:
243:
244: /// -----------------------------------------------------------------------
245: /// Configuration of CCU6 Channel 3:
246: /// -----------------------------------------------------------------------
247: /// - T13 output is not inverted
248:
249:
250: CCU6_CC63SRL = 0x00; // load CCU6 capture/compare shadow register
0000E9 F59A MOV CCU6_CC63SRL,A
251: // low for channel 3
252: CCU6_CC63SRH = 0x00; // load CCU6 capture/compare shadow register
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -