📄 pwmart.ls
字号:
1 ; C Compiler for ST7 (COSMIC Software)
2 ; Generator V4.4a - 17 Dec 2001
3 ; Optimizer V4.2g - 21 Dec 2001
1561 ; 81 void ART_Init(void)
1561 ; 82 {
1562 switch .text
1563 0000 _ART_Init:
1566 ; 83 ARTICCSR = 0; // No capture
1568 0000 4f clr a
1569 0001 b77c ld _ARTICCSR,a
1570 ; 84 PWMCR = 0; // No PWM
1572 0003 b778 ld _PWMCR,a
1573 ; 85 ARTCAR = 0; // Reset counter
1575 0005 b77a ld _ARTCAR,a
1576 ; 86 ARTCSR = 0; // Clr pending OVF interrupt
1578 0007 b779 ld _ARTCSR,a
1579 ; 88 ARTARR = TB_UNIT; // Time base Unit also depends from CLK prescaler below
1581 0009 a606 ld a,#6
1582 000b b77b ld _ARTARR,a
1583 ; 90 ARTCSR = ARTCSR_CC2_OR + ARTCSR_CC0_OR + ARTCSR_FCRL_OR + ARTCSR_OIE_OR;
1585 000d a656 ld a,#86
1586 000f b779 ld _ARTCSR,a
1587 ; 93 TimeBaseStatus = 0;
1589 0011 4f clr a
1590 0012 c70015 ld L7401_TimeBaseStatus,a
1591 ; 94 Status = 0;
1593 0015 c70014 ld L1501_Status,a
1594 ; 95 TimeOutCounter = U16_MAX;
1596 0018 aeff ld x,#255
1597 001a cf000e ld L3601_TimeOutCounter,x
1598 001d 4a dec a
1599 001e c7000f ld L3601_TimeOutCounter+1,a
1600 ; 96 TimeOutPeriod = U16_MAX;
1602 0021 cf000c ld L5601_TimeOutPeriod,x
1603 0024 a6ff ld a,#255
1604 0026 c7000d ld L5601_TimeOutPeriod+1,a
1605 ; 97 RegCounter = U8_MAX;
1607 0029 c70013 ld L3501_RegCounter,a
1608 ; 98 RegTimeBase = U8_MAX;
1610 002c c70012 ld L5501_RegTimeBase,a
1611 ; 99 SequenceCounter = U16_MAX;
1613 002f cf000a ld L7601_SequenceCounter,x
1614 0032 c7000b ld L7601_SequenceCounter+1,a
1615 ; 100 SequencePeriod = U16_MAX;
1617 0035 cf0008 ld L1701_SequencePeriod,x
1618 0038 c70009 ld L1701_SequencePeriod+1,a
1619 ; 101 ms_Counter = U16_MAX;
1621 003b cf0006 ld L3701_ms_Counter,x
1622 003e c70007 ld L3701_ms_Counter+1,a
1623 ; 102 ms_TimeBase = U16_MAX;
1625 0041 cf0004 ld L5701_ms_TimeBase,x
1626 0044 c70005 ld L5701_ms_TimeBase+1,a
1627 ; 103 MainTimeBase = U16_MAX;
1629 0047 cf0000 ld L1011_MainTimeBase,x
1630 004a c70001 ld L1011_MainTimeBase+1,a
1631 ; 104 MainCounter = U16_MAX;
1633 004d cf0002 ld L7701_MainCounter,x
1634 0050 c70003 ld L7701_MainCounter+1,a
1635 ; 106 WdgTimeBase = U8_MAX;
1637 0053 c70011 ld L7501_WdgTimeBase,a
1638 ; 107 WdgCounter = U8_MAX;
1640 0056 c70010 ld L1601_WdgCounter,a
1641 ; 109 DebounceButton = 0;
1643 0059 4f clr a
1644 005a c70016 ld _DebounceButton,a
1645 ; 110 }
1648 005d 81 ret
1671 ; 121 void ART_Start(void)
1671 ; 122 {
1672 switch .text
1673 005e _ART_Start:
1676 ; 123 ARTCSR |= ARTCSR_TCE_OR; // Start timer
1678 005e b679 ld a,_ARTCSR
1679 0060 aa08 or a,#8
1680 0062 b779 ld _ARTCSR,a
1681 ; 124 }
1684 0064 81 ret
1721 ; 140 void ART_SetTimeOutDuration(u16 Duration)
1721 ; 141 {
1722 switch .text
1724 xref.b _ART_SetTimeOutDuration$L
1725 0065 _ART_SetTimeOutDuration:
1727 0065 b701 ld _ART_SetTimeOutDuration$L+1,a
1728 0067 bf00 ld _ART_SetTimeOutDuration$L,x
1730 ; 142 if ( Duration == 0)
1732 0069 4d tnz a
1733 006a 2609 jrne L7411
1734 006c 5d tnz x
1735 006d 2606 jrne L7411
1736 ; 144 Duration = 1; // Min value is 1ms
1738 006f a601 ld a,#1
1739 0071 b701 ld _ART_SetTimeOutDuration$L+1,a
1740 0073 3f00 clr _ART_SetTimeOutDuration$L
1741 0075 L7411:
1742 ; 146 TimeBaseStatus |= TIMEOUT_LOCK; // Lock TimeOut handling in interrupt
1744 0075 c60015 ld a,L7401_TimeBaseStatus
1745 0078 aa10 or a,#16
1746 007a c70015 ld L7401_TimeBaseStatus,a
1747 ; 147 TimeOutPeriod = Duration; // Value autoreloaded when counter = 0
1749 007d be00 ld x,_ART_SetTimeOutDuration$L
1750 007f cf000c ld L5601_TimeOutPeriod,x
1751 0082 b601 ld a,_ART_SetTimeOutDuration$L+1
1752 0084 c7000d ld L5601_TimeOutPeriod+1,a
1753 ; 148 TimeOutCounter = Duration; // Reset counter to new value
1755 0087 cf000e ld L3601_TimeOutCounter,x
1756 008a c7000f ld L3601_TimeOutCounter+1,a
1757 ; 149 TimeBaseStatus &= (u8)(~TIMEOUT_ELAPSED); // Clear Flag
1759 008d c60015 ld a,L7401_TimeBaseStatus
1760 0090 a4fe and a,#254
1761 0092 c70015 ld L7401_TimeBaseStatus,a
1762 ; 150 TimeBaseStatus &= (u8)(~TIMEOUT_LOCK); // Unlock TimeOut handling in interrupt
1764 0095 c60015 ld a,L7401_TimeBaseStatus
1765 0098 a4ef and a,#239
1766 009a c70015 ld L7401_TimeBaseStatus,a
1767 ; 151 }
1770 009d 81 ret
1807 ; 153 void ART_SetSpeedRegPeriod(u8 Period)
1807 ; 154 {
1808 switch .text
1810 xref.b _ART_SetSpeedRegPeriod$L
1811 009e _ART_SetSpeedRegPeriod:
1814 ; 155 if ( Period == 0) Period = 1; // Min value is 1ms
1816 009e 4d tnz a
1817 009f 2602 jrne L7611
1820 00a1 a601 ld a,#1
1821 00a3 L7611:
1822 ; 156 RegTimeBase = Period; // Value autoreloaded when counter = 0
1824 00a3 c70012 ld L5501_RegTimeBase,a
1825 ; 157 RegCounter = Period; // Reset counter to new value
1827 00a6 c70013 ld L3501_RegCounter,a
1828 ; 158 TimeBaseStatus &= (u8)(~REG_PERIOD_ELAPSED); // Clear Flag
1830 00a9 c60015 ld a,L7401_TimeBaseStatus
1831 00ac a4fd and a,#253
1832 00ae c70015 ld L7401_TimeBaseStatus,a
1833 ; 159 }
1836 00b1 81 ret
1873 ; 161 void ART_SetSequenceDuration(u16 Duration)
1873 ; 162 {
1874 switch .text
1876 xref.b _ART_SetSequenceDuration$L
1877 00b2 _ART_SetSequenceDuration:
1879 00b2 b701 ld _ART_SetSequenceDuration$L+1,a
1880 00b4 bf00 ld _ART_SetSequenceDuration$L,x
1882 ; 163 if ( Duration == 0)
1884 00b6 4d tnz a
1885 00b7 2609 jrne L7021
1886 00b9 5d tnz x
1887 00ba 2606 jrne L7021
1888 ; 165 Duration = 1; // Min value is 1ms
1890 00bc a601 ld a,#1
1891 00be b701 ld _ART_SetSequenceDuration$L+1,a
1892 00c0 3f00 clr _ART_SetSequenceDuration$L
1893 00c2 L7021:
1894 ; 167 TimeBaseStatus |= SEQUENCE_LOCK; // Lock TimeOut handling in interrupt
1896 00c2 c60015 ld a,L7401_TimeBaseStatus
1897 00c5 aa20 or a,#32
1898 00c7 c70015 ld L7401_TimeBaseStatus,a
1899 ; 168 SequencePeriod = Duration; // Value autoreloaded when counter = 0
1901 00ca be00 ld x,_ART_SetSequenceDuration$L
1902 00cc cf0008 ld L1701_SequencePeriod,x
1903 00cf b601 ld a,_ART_SetSequenceDuration$L+1
1904 00d1 c70009 ld L1701_SequencePeriod+1,a
1905 ; 169 SequenceCounter = Duration; // Reset counter to new value
1907 00d4 cf000a ld L7601_SequenceCounter,x
1908 00d7 c7000b ld L7601_SequenceCounter+1,a
1909 ; 170 TimeBaseStatus &= (u8)(~SEQUENCE_COMPLETED); // Clear Flag
1911 00da c60015 ld a,L7401_TimeBaseStatus
1912 00dd a4fb and a,#251
1913 00df c70015 ld L7401_TimeBaseStatus,a
1914 ; 171 TimeBaseStatus &= (u8)(~SEQUENCE_LOCK); // Unlock TimeOut handling in interrupt
1916 00e2 c60015 ld a,L7401_TimeBaseStatus
1917 00e5 a4df and a,#223
1918 00e7 c70015 ld L7401_TimeBaseStatus,a
1919 ; 172 }
1922 00ea 81 ret
1958 ; 174 void ART_Set_TimeInMs(u16 Duration)
1958 ; 175 {
1959 switch .text
1961 xref.b _ART_Set_TimeInMs$L
1962 00eb _ART_Set_TimeInMs:
1964 00eb b701 ld _ART_Set_TimeInMs$L+1,a
1965 00ed bf00 ld _ART_Set_TimeInMs$L,x
1967 ; 176 if ( Duration == 0)
1969 00ef 4d tnz a
1970 00f0 2609 jrne L7221
1971 00f2 5d tnz x
1972 00f3 2606 jrne L7221
1973 ; 178 Duration = 1; // Min value is 1ms
1975 00f5 a601 ld a,#1
1976 00f7 b701 ld _ART_Set_TimeInMs$L+1,a
1977 00f9 3f00 clr _ART_Set_TimeInMs$L
1978 00fb L7221:
1979 ; 180 TimeBaseStatus |= MS_TIME_LOCK; // Lock TimeOut handling in interrupt
1981 00fb c60015 ld a,L7401_TimeBaseStatus
1982 00fe aa40 or a,#64
1983 0100 c70015 ld L7401_TimeBaseStatus,a
1984 ; 181 ms_TimeBase = Duration; // Value autoreloaded when counter = 0
1986 0103 be00 ld x,_ART_Set_TimeInMs$L
1987 0105 cf0004 ld L5701_ms_TimeBase,x
1988 0108 b601 ld a,_ART_Set_TimeInMs$L+1
1989 010a c70005 ld L5701_ms_TimeBase+1,a
1990 ; 182 ms_Counter = Duration; // Reset counter to new value
1992 010d cf0006 ld L3701_ms_Counter,x
1993 0110 c70007 ld L3701_ms_Counter+1,a
1994 ; 183 TimeBaseStatus &= (u8)(~MS_TIME_ELAPSED); // Clear Flag
1996 0113 c60015 ld a,L7401_TimeBaseStatus
1997 0116 a4f7 and a,#247
1998 0118 c70015 ld L7401_TimeBaseStatus,a
1999 ; 184 TimeBaseStatus &= (u8)(~MS_TIME_LOCK); // Unlock TimeOut handling in interrupt
2001 011b c60015 ld a,L7401_TimeBaseStatus
2002 011e a4bf and a,#191
2003 0120 c70015 ld L7401_TimeBaseStatus,a
2004 ; 185 }
2007 0123 81 ret
2044 ; 187 void ART_SetMainTimeBase(u8 Period)
2044 ; 188 {
2045 switch .text
2047 xref.b _ART_SetMainTimeBase$L
2048 0124 _ART_SetMainTimeBase:
2051 ; 189 if ( Period == 0) Period = 1; // Min value is 1ms
2053 0124 4d tnz a
2054 0125 2602 jrne L7421
2057 0127 a601 ld a,#1
2058 0129 L7421:
2059 0129 b700 ld _ART_SetMainTimeBase$L,a
2060 ; 190 MainTimeBase = Period*10; // Value autoreloaded when counter = 0
2062 012b ae0a ld x,#10
2063 012d 42 mul x,a
2064 012e cf0000 ld L1011_MainTimeBase,x
2065 0131 c70001 ld L1011_MainTimeBase+1,a
2066 ; 191 MainCounter = Period*10; // Reset counter to new value
2068 0134 b600 ld a,_ART_SetMainTimeBase$L
2069 0136 ae0a ld x,#10
2070 0138 42 mul x,a
2071 0139 cf0002 ld L7701_MainCounter,x
2072 013c c70003 ld L7701_MainCounter+1,a
2073 ; 192 TimeBaseStatus &= (u8)(~MAIN_TIMEBASE_ELAPSED); // Clear Flag
2075 013f c60015 ld a,L7401_TimeBaseStatus
2076 0142 a47f and a,#127
2077 0144 c70015 ld L7401_TimeBaseStatus,a
2078 ; 193 }
2081 0147 81 ret
2118 ; 195 void ART_SetWdgRfrshTime(u8 Period)
2118 ; 196 {
2119 switch .text
2121 xref.b _ART_SetWdgRfrshTime$L
2122 0148 _ART_SetWdgRfrshTime:
2125 ; 197 if ( Period == 0) Period = 1; // Min value is 1ms
2127 0148 4d tnz a
2128 0149 2602 jrne L7621
2131 014b a601 ld a,#1
2132 014d L7621:
2133 ; 198 WdgTimeBase = Period; // Value autoreloaded when counter = 0
2135 014d c70011 ld L7501_WdgTimeBase,a
2136 ; 199 WdgCounter = Period; // Reset counter to new value
2138 0150 c70010 ld L1601_WdgCounter,a
2139 ; 200 Status &= (u8)(~WDG_TIMEBASE_ELAPSED); // Clear Flag
2141 0153 c60014 ld a,L1501_Status
2142 0156 a4fe and a,#254
2143 0158 c70014 ld L1501_Status,a
2144 ; 201 }
2147 015b 81 ret
2171 ; 213 BOOL ART_IsTimeOutElapsed(void)
2171 ; 214 {
2172 switch .text
2173 015c _ART_IsTimeOutElapsed:
2176 ; 215 if ( TimeBaseStatus & TIMEOUT_ELAPSED )
2178 015c c60015 ld a,L7401_TimeBaseStatus
2179 015f a501 bcp a,#1
2180 0161 270b jreq L1031
2181 ; 217 TimeBaseStatus &= (u8)(~TIMEOUT_ELAPSED); // Clear Flag
2183 0163 c60015 ld a,L7401_TimeBaseStatus
2184 0166 a4fe and a,#254
2185 0168 c70015 ld L7401_TimeBaseStatus,a
2186 ; 218 return ( TRUE );
2188 016b a601 ld a,#1
2191 016d 81 ret
2192 016e L1031:
2193 ; 222 return ( FALSE );
2195 016e 4f clr a
2198 016f 81 ret
2222 ; 227 BOOL ART_IsRegPeriodElapsed(void)
2222 ; 228 {
2223 switch .text
2224 0170 _ART_IsRegPeriodElapsed:
2227 ; 229 if ( TimeBaseStatus & REG_PERIOD_ELAPSED )
2229 0170 c60015 ld a,L7401_TimeBaseStatus
2230 0173 a502 bcp a,#2
2231 0175 270b jreq L5131
2232 ; 231 TimeBaseStatus &= (u8)(~REG_PERIOD_ELAPSED); // Clear Flag
2234 0177 c60015 ld a,L7401_TimeBaseStatus
2235 017a a4fd and a,#253
2236 017c c70015 ld L7401_TimeBaseStatus,a
2237 ; 232 return ( TRUE );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -