📄 main.ls
字号:
1 ; C Compiler for ST7 (COSMIC Software)
2 ; Generator V4.4a - 17 Dec 2001
3 ; Optimizer V4.2g - 21 Dec 2001
1576 ; 66 void main(void)
1576 ; 67 {
1577 switch .text
1579 xref.b _main$L
1580 0000 _main:
1583 ; 69 ST7_IntPrioritySetUp();
1585 0000 cd0000 call _ST7_IntPrioritySetUp
1587 ; 70 PORTS_Init();
1589 0003 cd0000 call _PORTS_Init
1591 ; 71 ADC_Init();
1593 0006 cd0000 call _ADC_Init
1595 ; 72 ART_Init(); // PWM ART provided general purpose time bases
1597 0009 cd0000 call _ART_Init
1599 ; 73 ACM_Init();
1601 000c cd0000 call _ACM_Init
1603 ; 81 ART_SetMainTimeBase(10); // 100ms timebase for LED Toggle
1605 000f a60a ld a,#10
1606 0011 cd0000 call _ART_SetMainTimeBase
1608 ; 83 EnableInterrupts();
1611 0014 9a rim
1613 ; 85 ART_Start(); // Time bases are now available
1616 0015 cd0000 call _ART_Start
1618 ; 86 State = IDLE;
1620 0018 4f clr a
1621 0019 c70000 ld L7401_State,a
1622 ; 89 PORTS_GreenLedOn();
1624 001c cd0000 call _PORTS_GreenLedOn
1627 001f L3311:
1628 ; 90 while (!ART_IsMainTimeElapsed());
1630 001f cd0000 call _ART_IsMainTimeElapsed
1632 0022 4d tnz a
1633 0023 27fa jreq L3311
1634 ; 91 PORTS_RedLedOn();
1636 0025 cd0000 call _PORTS_RedLedOn
1639 0028 L1411:
1640 ; 92 while (!ART_IsMainTimeElapsed());
1642 0028 cd0000 call _ART_IsMainTimeElapsed
1644 002b 4d tnz a
1645 002c 27fa jreq L1411
1646 ; 93 PORTS_GreenLedOn();
1648 002e LC001:
1650 002e cd0000 call _PORTS_GreenLedOn
1652 0031 L5411:
1653 ; 98 switch ( State )
1655 0031 c60000 ld a,L7401_State
1657 0034 2711 jreq L1601
1658 0036 4a dec a
1659 0037 271f jreq L3601
1660 0039 4a dec a
1661 003a 2721 jreq L5601
1662 003c 4a dec a
1663 003d 272e jreq L7601
1664 003f 4a dec a
1665 0040 2755 jreq L1701
1666 0042 4a dec a
1667 0043 276b jreq L3701
1668 0045 2072 jra L5701
1669 0047 L1601:
1670 ; 100 case IDLE: if ( PORTS_KeyScan() == TRUE ) // Start motor
1672 0047 cd0000 call _PORTS_KeyScan
1674 004a a101 cp a,#1
1675 004c 2673 jrne L3511
1676 ; 103 ACM_InitSoftStart(START_FREQ);
1678 004e 5f clr x
1679 004f a696 ld a,#150
1680 0051 cd0000 call _ACM_InitSoftStart
1682 ; 107 State = START;
1684 0054 a601 ld a,#1
1685 0056 2066 jp LC002
1686 0058 L3601:
1687 ; 111 case START: State = StartMotor();
1689 0058 cd01b4 call L3501_StartMotor
1691 ; 112 break;
1693 005b 2061 jp LC002
1694 005d L5601:
1695 ; 114 case RUN: if ( PORTS_KeyScan() == TRUE ) // Stop motor
1697 005d cd0000 call _PORTS_KeyScan
1699 0060 a101 cp a,#1
1700 0062 2604 jrne L7511
1701 ; 116 State = STOP;
1703 0064 a603 ld a,#3
1705 0066 2056 jp LC002
1706 0068 L7511:
1707 ; 120 DoMotorControl();
1709 0068 cd0123 call L1501_DoMotorControl
1711 006b 2054 jra L3511
1712 006d L7601:
1713 ; 127 BrakingTorque = BRAKE_DUTY_CYCLE;
1715 006d a640 ld a,#64
1716 006f b7ff ld _main$L-1,a
1717 0071 3ffe clr _main$L-2
1718 ; 128 if (BrakingTorque == 0)
1720 0073 bafe or a,_main$L-2
1721 0075 260e jrne L3611
1722 ; 130 ART_SetTimeOutDuration(1000);
1724 0077 a6e8 ld a,#232
1725 0079 ae03 ld x,#3
1726 007b cd0000 call _ART_SetTimeOutDuration
1728 ; 131 MTC_DisableMCOutputs(); // PWM is disabled on MCO outputs
1730 007e cd0000 call _MTC_DisableMCOutputs
1732 ; 132 State = WAIT;
1734 0081 a605 ld a,#5
1736 0083 2039 jp LC002
1737 0085 L3611:
1738 ; 136 MTC_StartBraking( BrakingTorque );
1740 0085 b6ff ld a,_main$L-1
1741 0087 befe ld x,_main$L-2
1742 0089 cd0000 call _MTC_StartBraking
1744 ; 137 ART_SetTimeOutDuration(BRAKE_DURATION);
1746 008c a6b8 ld a,#184
1747 008e ae0b ld x,#11
1748 0090 cd0000 call _ART_SetTimeOutDuration
1750 ; 138 State = BRAKE;
1752 0093 a604 ld a,#4
1753 0095 2027 jp LC002
1754 0097 L1701:
1755 ; 143 case BRAKE: if (!ART_IsTimeOutElapsed())
1757 0097 cd0000 call _ART_IsTimeOutElapsed
1759 009a 4d tnz a
1760 009b 2605 jrne L7611
1761 ; 145 MTC_Brake();
1763 009d cd0000 call _MTC_Brake
1766 00a0 201f jra L3511
1767 00a2 L7611:
1768 ; 149 MTC_StopBraking();
1770 00a2 cd0000 call _MTC_StopBraking
1772 ; 150 ART_SetTimeOutDuration(1000);
1774 00a5 a6e8 ld a,#232
1775 00a7 ae03 ld x,#3
1776 00a9 cd0000 call _ART_SetTimeOutDuration
1778 ; 151 State = WAIT;
1780 00ac a605 ld a,#5
1781 00ae 200e jp LC002
1782 00b0 L3701:
1783 ; 155 case WAIT: if (ART_IsTimeOutElapsed())
1785 00b0 cd0000 call _ART_IsTimeOutElapsed
1787 00b3 4d tnz a
1788 00b4 270b jreq L3511
1789 ; 157 State = IDLE;
1791 00b6 4f clr a
1792 00b7 2005 jp LC002
1793 00b9 L5701:
1794 ; 161 case FAULT:
1794 ; 162 default: MTC_DisableMCOutputs(); // PWM is disabled on MCO outputs
1796 00b9 cd0000 call _MTC_DisableMCOutputs
1798 ; 163 State = FAULT;
1800 00bc a606 ld a,#6
1801 00be LC002:
1802 00be c70000 ld L7401_State,a
1803 ; 164 break;
1805 00c1 L3511:
1806 ; 168 CheckPowerStage();
1808 00c1 ad2c call L5501_CheckPowerStage
1810 ; 171 if (ART_IsMainTimeElapsed())
1812 00c3 cd0000 call _ART_IsMainTimeElapsed
1814 00c6 4d tnz a
1815 00c7 2603cc0031 jreq L5411
1816 ; 173 switch ( State )
1818 00cc c60000 ld a,L7401_State
1820 00cf 2603cc002e jreq LC001
1821 00d4 4a dec a
1822 00d5 270c jreq L1011
1823 00d7 4a dec a
1824 00d8 2709 jreq L1011
1825 00da 4a dec a
1826 00db 2706 jreq L1011
1827 00dd 4a dec a
1828 00de 2703 jreq L1011
1829 00e0 4a dec a
1830 00e1 2606 jrne L3011
1831 ; 175 case IDLE: PORTS_GreenLedOn();
1833 ; 176 break;
1835 00e3 L1011:
1836 ; 177 case START:
1836 ; 178 case RUN:
1836 ; 179 case STOP:
1836 ; 180 case BRAKE:
1836 ; 181 case WAIT: PORTS_RedLedOn();
1838 00e3 cd0000 call _PORTS_RedLedOn
1840 ; 182 break;
1842 00e6 cc0031 jra L5411
1843 00e9 L3011:
1844 ; 183 case FAULT:
1844 ; 184 default: PORTS_RedLedToggle();
1846 00e9 cd0000 call _PORTS_RedLedToggle
1848 ; 185 break;
1850 00ec cc0031 jra L5411
1876 ; 205 void CheckPowerStage(void)
1876 ; 206 {
1877 switch .text
1878 00ef L5501_CheckPowerStage:
1881 ; 208 if (ADC_CheckOverVoltage() || ADC_CheckOverTemp() || MTC_CheckEmergencyStop())
1883 00ef cd0000 call _ADC_CheckOverVoltage
1885 00f2 4d tnz a
1886 00f3 260c jrne L5121
1888 00f5 cd0000 call _ADC_CheckOverTemp
1890 00f8 4d tnz a
1891 00f9 2606 jrne L5121
1893 00fb cd0000 call _MTC_CheckEmergencyStop
1895 00fe 4d tnz a
1896 00ff 2705 jreq L3121
1897 0101 L5121:
1898 ; 210 State = FAULT;
1900 0101 a606 ld a,#6
1901 0103 c70000 ld L7401_State,a
1902 0106 L3121:
1903 ; 213 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -