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

📄 mtc.ls

📁 该程序是ST7MC驱动三洋压缩机(交流)
💻 LS
📖 第 1 页 / 共 5 页
字号:
1898  0013 81            	ret	
1922                     ; 143 void MTC_DisableMCOutputs(void)
1922                     ; 144 {
1923                     	switch	.text
1924  0014               _MTC_DisableMCOutputs:
1927                     ; 145 	MCRA &= ((1<<MCRA_MOE)^255);
1929  0014 b65a          	ld	a,_MCRA
1930  0016 a47f          	and	a,#127
1931  0018 b75a          	ld	_MCRA,a
1932                     ; 146 }
1935  001a 81            	ret	
1982                     ; 160 void MTC_InitPeripheral(void)
1982                     ; 161 {
1983                     	switch	.text
1984  001b               _MTC_InitPeripheral:
1987                     ; 163 	MTC_ResetPeripheral();
1989  001b ade3          	call	_MTC_ResetPeripheral
1991                     ; 165 	SET_MTC_PAGE(1);
1993  001d b65f          	ld	a,_MCFR
1994  001f aa80          	or	a,#128
1995  0021 b75f          	ld	_MCFR,a
1996                     ; 166 	MPOL = L6386_POLARITY;		// Set polarity according to IGBT drivers
1998  0023 a63f          	ld	a,#63
1999  0025 b751          	ld	_MPOL,a
2000                     ; 167 	MDTG = DEADTIME;				// Deadtime Duration
2002  0027 a604          	ld	a,#4
2003  0029 b750          	ld	_MDTG,a
2004                     ; 168 	SetBit(MDTG,DTE);				// Deadtime enabled
2006  002b b650          	ld	a,_MDTG
2007  002d aa40          	or	a,#64
2008  002f b750          	ld	_MDTG,a
2009                     ; 169 	SetBit(MDTG,PCN);				// Three independant PWM configuration
2011  0031 b650          	ld	a,_MDTG
2012  0033 aa80          	or	a,#128
2013  0035 b750          	ld	_MDTG,a
2014                     ; 170 	MPWME = DG_MSK;				// Use Debug outputs
2016  0037 a680          	ld	a,#128
2017  0039 b752          	ld	_MPWME,a
2018                     ; 171 	MPAR = TACHO_FALLING;		// Speed Sensor mode enabled, falling edge sensitive
2020  003b b754          	ld	_MPAR,a
2021                     ; 172 	SET_MTC_PAGE(0);
2023  003d b65f          	ld	a,_MCFR
2024  003f a47f          	and	a,#127
2025  0041 b75f          	ld	_MCFR,a
2026                     ; 174 	MPCR = PWM_PRSC;
2028  0043 4f            	clr	a
2029  0044 b761          	ld	_MPCR,a
2030                     ; 175 	SetBit(MPCR,MPCR_CMS);		// Centered pattern
2032  0046 b661          	ld	a,_MPCR
2033  0048 aa08          	or	a,#8
2034  004a b761          	ld	_MPCR,a
2035                     ; 176 	MREP = 1;						// Preload registers are loaded every PWM cycle
2037  004c a601          	ld	a,#1
2038  004e b762          	ld	_MREP,a
2039                     ; 177 	MCP0L = (u8)PWM_MCP0;		// Set PWM frequency
2041  0050 a67f          	ld	a,#127
2042  0052 b76a          	ld	_MCP0L,a
2043                     ; 178 	MCP0H = ((u8)(PWM_MCP0>>8));
2045  0054 a602          	ld	a,#2
2046  0056 b769          	ld	_MCP0H,a
2047                     ; 180 	ToCMPxL(MCPUL,PWM_MCP0/2);	// 50% duty cycle on U
2049  0058 a6f8          	ld	a,#248
2050  005a b768          	ld	_MCPUL,a
2051                     ; 181 	ToCMPxH(MCPUH,PWM_MCP0/2);	
2053  005c a609          	ld	a,#9
2054  005e b767          	ld	_MCPUH,a
2055                     ; 182 	ToCMPxL(MCPVL,PWM_MCP0/2);	// 50% duty cycle on V
2057  0060 a6f8          	ld	a,#248
2058  0062 b766          	ld	_MCPVL,a
2059                     ; 183 	ToCMPxH(MCPVH,PWM_MCP0/2);
2061  0064 a609          	ld	a,#9
2062  0066 b765          	ld	_MCPVH,a
2063                     ; 184 	ToCMPxL(MCPWL,PWM_MCP0/2);	// 50% duty cycle on W
2065  0068 a6f8          	ld	a,#248
2066  006a b764          	ld	_MCPWL,a
2067                     ; 185 	ToCMPxH(MCPWH,PWM_MCP0/2);
2069  006c a609          	ld	a,#9
2070  006e b763          	ld	_MCPWH,a
2071                     ; 187 	SetBit(MCRA,MCRA_DAC);	// Direct access mode to write into MPHST
2073  0070 b65a          	ld	a,_MCRA
2074  0072 aa10          	or	a,#16
2075  0074 b75a          	ld	_MCRA,a
2076                     ; 188 	MPHST = MCIC;				// Comparator input for Tacho signal
2078  0076 a680          	ld	a,#128
2079  0078 b75d          	ld	_MPHST,a
2080                     ; 189 	ClrBit(MCRA,MCRA_DAC);	// Disable direct access
2082  007a b65a          	ld	a,_MCRA
2083  007c a4ef          	and	a,#239
2084  007e b75a          	ld	_MCRA,a
2085                     ; 191 	MISR = 0;				// Clear pending interrupts
2087  0080 4f            	clr	a
2088  0081 b759          	ld	_MISR,a
2089                     ; 192 	MTCStatus = 0;
2091  0083 3f10          	clr	_MTCStatus
2092                     ; 193 	MCES_Status = FALSE;
2094  0085 c70000        	ld	L5701_MCES_Status,a
2095                     ; 195 	SpeedFIFO_Index = (PSpeedMeas_s)SensorPeriod;
2097  0088 ae02          	ld	x,#high(_SensorPeriod)
2098  008a bf00          	ld	_SpeedFIFO_Index,x
2099  008c a602          	ld	a,#low(_SensorPeriod)
2100  008e b701          	ld	_SpeedFIFO_Index+1,a
2101                     ; 197 	MTC_Set_CounterClockWise_Direction();
2103  0090 cd0342        	call	_MTC_Set_CounterClockWise_Direction
2105                     ; 199 	MTC_EnableClock();				// Enable peripheral clock and update active 
2107  0093 b65a          	ld	a,_MCRA
2108  0095 aa40          	or	a,#64
2109  0097 b75a          	ld	_MCRA,a
2110                     ; 202 	MIMR = MIMR_PUM_OR + MIMR_RIM_OR + MIMR_CIM_OR + MIMR_EIM_OR;
2112  0099 a6a9          	ld	a,#169
2113  009b b758          	ld	_MIMR,a
2114                     ; 203 }
2117  009d 81            	ret	
2145                     ; 215 void MTC_InitSineGen(void)
2145                     ; 216 {
2146                     	switch	.text
2147  009e               _MTC_InitSineGen:
2150                     ; 217 	SineFreq = U8_MAX;				// Arbitrary value
2152  009e 5f            	clr	x
2153  009f bf14          	ld	_SineFreq,x
2154  00a1 a6ff          	ld	a,#255
2155  00a3 b715          	ld	_SineFreq+1,a
2156                     ; 218 	SineMag = 0;
2158  00a5 3f16          	clr	_SineMag
2159                     ; 219 	MTC_Set_ClockWise_Direction();
2161  00a7 cd033d        	call	_MTC_Set_ClockWise_Direction
2163                     ; 220 	Phase = 0;
2165  00aa 3f0e          	clr	_Phase
2166  00ac 3f0f          	clr	_Phase+1
2167                     ; 221 	StatorFreq = FREQ_INIT-1;               // This ensure that Sinewave will be updated
2169  00ae a631          	ld	a,#49
2170  00b0 c70006        	ld	L7601_StatorFreq+1,a
2171  00b3 4f            	clr	a
2172  00b4 c70005        	ld	L7601_StatorFreq,a
2173                     ; 222    MTC_UpdateSine( VOLT_INIT, FREQ_INIT);
2175  00b7 a632          	ld	a,#50
2176  00b9 b702          	ld	_MTC_UpdateSine$L+2,a
2177  00bb 3f01          	clr	_MTC_UpdateSine$L+1
2178  00bd 4f            	clr	a
2180                     ; 223 }
2183  00be 2000          	jp	_MTC_UpdateSine
2248                     	switch	.const
2249  0100               L22:
2250  0100 000001ea      	dc.l	490
2251  0104               L42:
2252  0104 000001e9      	dc.l	489
2253                     ; 245 BOOL MTC_UpdateSine (u8 NewVoltage, u16 NewFrequency)
2253                     ; 246 {
2254                     	switch	.text
2256                     	xref.b	_MTC_UpdateSine$L
2257  00c0               _MTC_UpdateSine:
2259  00c0 b700          	ld	_MTC_UpdateSine$L,a
2261                     ; 255 	if (NewFrequency != StatorFreq)
2263  00c2 b602          	ld	a,_MTC_UpdateSine$L+2
2264  00c4 c10006        	cp	a,L7601_StatorFreq+1
2265  00c7 2605          	jrne	L02
2266  00c9 be01          	ld	x,_MTC_UpdateSine$L+1
2267  00cb c30005        	cp	x,L7601_StatorFreq
2268  00ce               L02:
2269  00ce 2603cc0164    	jreq	L7021
2270                     ; 257 		if (!(MTCStatus & FREQ_CHANGE))	// ... unless an updation is on-going
2272  00d3 011003cc0162  	btjt	_MTCStatus,#0,L1121
2273                     ; 260       	PrevStatorFreq = StatorFreq;	
2275  00d9 ce0005        	ld	x,L7601_StatorFreq
2276  00dc cf0003        	ld	L1701_PrevStatorFreq,x
2277  00df c60006        	ld	a,L7601_StatorFreq+1
2278  00e2 c70004        	ld	L1701_PrevStatorFreq+1,a
2279                     ; 261 			StatorFreq = NewFrequency;
2281  00e5 be01          	ld	x,_MTC_UpdateSine$L+1
2282  00e7 cf0005        	ld	L7601_StatorFreq,x
2283  00ea b602          	ld	a,_MTC_UpdateSine$L+2
2284  00ec c70006        	ld	L7601_StatorFreq+1,a
2285                     ; 264 			if ( NewFrequency >= HIGHEST_FREQ )
2287  00ef a048          	sub	a,#72
2288  00f1 9f            	ld	a,x
2289  00f2 a20d          	sbc	a,#13
2290  00f4 2510          	jrult	L3121
2291                     ; 266 				ExtendedFreq = (u32)HIGHEST_FREQ * (u32)256;
2293  00f6 4f            	clr	a
2294  00f7 b7ff          	ld	_MTC_UpdateSine$L-1,a
2295  00f9 a648          	ld	a,#72
2296  00fb b7fe          	ld	_MTC_UpdateSine$L-2,a
2297  00fd a60d          	ld	a,#13
2298  00ff b7fd          	ld	_MTC_UpdateSine$L-3,a
2299  0101 4f            	clr	a
2300  0102 b7fc          	ld	_MTC_UpdateSine$L-4,a
2302  0104 2027          	jra	L5121
2303  0106               L3121:
2304                     ; 270 				if ( NewFrequency < LOWEST_FREQ )
2306  0106 b602          	ld	a,_MTC_UpdateSine$L+2
2307  0108 a01e          	sub	a,#30
2308  010a b601          	ld	a,_MTC_UpdateSine$L+1
2309  010c a200          	sbc	a,#0
2310  010e 240e          	jruge	L7121
2311                     ; 272 					ExtendedFreq = (u32)LOWEST_FREQ * (u32)256;
2313  0110 4f            	clr	a
2314  0111 b7ff          	ld	_MTC_UpdateSine$L-1,a
2315  0113 a61e          	ld	a,#30
2316  0115 b7fe          	ld	_MTC_UpdateSine$L-2,a
2317  0117 4f            	clr	a
2318  0118 b7fd          	ld	_MTC_UpdateSine$L-3,a
2319  011a b7fc          	ld	_MTC_UpdateSine$L-4,a
2321  011c 200f          	jra	L5121
2322  011e               L7121:
2323                     ; 277 					ExtendedFreq = (u32)NewFrequency * (u32)256;
2325  011e b602          	ld	a,_MTC_UpdateSine$L+2
2326  0120 cd0000        	call	c_uitol
2328  0123 a608          	ld	a,#8
2329  0125 cd0000        	call	c_llsh
2331  0128 aefc          	ld	x,#_MTC_UpdateSine$L-4
2332  012a cd0000        	call	c_rtol
2334  012d               L5121:
2335                     ; 282 			if ( ExtendedFreq > (u32)STATOR_FREQ_RESOL )
2337  012d aefc          	ld	x,#_MTC_UpdateSine$L-4
2338  012f cd0000        	call	c_ltor
2340  0132 ae00          	ld	x,#high(L22)
2341  0134 bf00          	ld	c_x,x
2342  0136 ae00          	ld	x,#low(L22)
2343  0138 cd0000        	call	c_xlcmp
2345  013b 2516          	jrult	L3221
2346                     ; 284 				SineFreqBuf = (u16)((u32)ExtendedFreq / (u32)STATOR_FREQ_RESOL);
2348  013d aefc          	ld	x,#_MTC_UpdateSine$L-4
2349  013f cd0000        	call	c_ltor
2351  0142 ae04          	ld	x,#high(L42)
2352  0144 bf00          	ld	c_x,x
2353  0146 ae04          	ld	x,#low(L42)
2354  0148 cd0000        	call	c_xludv
2356  014b b603          	ld	a,c_lreg+3
2357  014d be02          	ld	x,c_lreg+2
2358  014f bf12          	ld	_SineFreqBuf,x
2360  0151 2005          	jra	L5221
2361  0153               L3221:
2362                     ; 288 				SineFreqBuf = 1; // Absolute minimum freq to avoid Freq=0 (DC current)
2364  0153 5f            	clr	x
2365  0154 bf12          	ld	_SineFreqBuf,x
2366  0156 a601          	ld	a,#1
2367  0158               L5221:
2368  0158 b713          	ld	_SineFreqBuf+1,a
2369                     ; 292 			MTCStatus |= FREQ_CHANGE;
2371  015a 1010          	bset	_MTCStatus,#0
2372                     ; 293 			UpdateStatus = TRUE;
2374  015c a601          	ld	a,#1
2375  015e b7fb          	ld	_MTC_UpdateSine$L-5,a
2377  0160 2002          	jra	L7021
2378  0162               L1121:
2379                     ; 297 			UpdateStatus = FALSE;
2381  0162 3ffb          	clr	_MTC_UpdateSine$L-5
2382  0164               L7021:
2383                     ; 304    SineMag = NewVoltage;
2385  0164 b600          	ld	a,_MTC_UpdateSine$L
2386  0166 b716          	ld	_SineMag,a
2387                     ; 306    return (UpdateStatus);
2389  0168 b6fb          	ld	a,_MTC_UpdateSine$L-5
2392  016a 81            	ret	
2417                     ; 319 u16  MTC_GetStatorFreq( void )
2417                     ; 320 {
2418                     	switch	.text
2419  016b               _MTC_GetStatorFreq:
2422                     ; 322 	if (!(MTCStatus & FREQ_CHANGE))
2424  016b 001007        	btjt	_MTCStatus,#0,L1421
2425                     ; 324 		return(StatorFreq);
2427  016e c60006        	ld	a,L7601_StatorFreq+1
2428  0171 ce0005        	ld	x,L7601_StatorFreq
2431  0174 81            	ret	
2432  0175               L1421:
2433                     ; 328 		return(PrevStatorFreq);
2435  0175 c60004        	ld	a,L1701_PrevStatorFreq+1
2436  0178 ce0003        	ld	x,L1701_PrevStatorFreq
2439  017b 81            	ret	
2462                     ; 339 u8 MTC_GetVoltage( void )
2462                     ; 340 {
2463                     	switch	.text
2464  017c               _MTC_GetVoltage:
2467                     ; 341     return (SineMag);
2469  017c b616          	ld	a,_SineMag
2472  017e 81            	ret	
2516                     ; 352 u16 MTC_GetSlip( void )
2516                     ; 353 {
2517                     	switch	.text
2519                     	xref.b	_MTC_GetSlip$L
2520  017f               _MTC_GetSlip:
2523                     ; 354     u16 RotorFreq  = MTC_GetRotorFreq();
2525  017f ad1f          	call	_MTC_GetRotorFreq
2527  0181 b7fd          	ld	_MTC_GetSlip$L-3,a
2528  0183 bffc          	ld	_MTC_GetSlip$L-4,x

⌨️ 快捷键说明

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