📄 timerx8_8h-source.html
字号:
00103 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span>00104 00105 <span class="comment">// for 4MHz crystal</span>00106 <span class="comment">// 0 = STOP (Timer not counting)</span>00107 <span class="comment">// 1 = CLOCK tics= 4MHz 8bitoverflow= 15625Hz 16bit= 61.035Hz</span>00108 <span class="comment">// 2 = CLOCK/8 tics= 500kHz 8bitoverflow= 1953.125Hz 16bit= 7.629Hz</span>00109 <span class="comment">// 3 = CLOCK/64 tics= 62500Hz 8bitoverflow= 244.141Hz 16bit= 0.954Hz</span>00110 <span class="comment">// 4 = CLOCK/256 tics= 15625Hz 8bitoverflow= 61.035Hz 16bit= 0.238Hz</span>00111 <span class="comment">// 5 = CLOCK/1024 tics= 3906.25Hz 8bitoverflow= 15.259Hz 16bit= 0.060Hz</span>00112 <span class="comment">// 6 = External Clock on T(x) pin (falling edge)</span>00113 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span>00114 00115 <span class="comment">// for 3.69MHz crystal</span>00116 <span class="comment">// 0 = STOP (Timer not counting)</span>00117 <span class="comment">// 1 = CLOCK tics= 3.69MHz 8bitoverflow= 14414Hz 16bit= 56.304Hz</span>00118 <span class="comment">// 2 = CLOCK/8 tics= 461250Hz 8bitoverflow= 1801.758Hz 16bit= 7.038Hz</span>00119 <span class="comment">// 3 = CLOCK/64 tics= 57625.25Hz 8bitoverflow= 225.220Hz 16bit= 0.880Hz</span>00120 <span class="comment">// 4 = CLOCK/256 tics= 14414.063Hz 8bitoverflow= 56.305Hz 16bit= 0.220Hz</span>00121 <span class="comment">// 5 = CLOCK/1024 tics= 3603.516Hz 8bitoverflow= 14.076Hz 16bit= 0.055Hz</span>00122 <span class="comment">// 6 = External Clock on T(x) pin (falling edge)</span>00123 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span>00124 00125 <span class="comment">// for 32.768KHz crystal on timer 2 (use for real-time clock)</span>00126 <span class="comment">// 0 = STOP</span>00127 <span class="comment">// 1 = CLOCK tics= 32.768kHz 8bitoverflow= 128Hz</span>00128 <span class="comment">// 2 = CLOCK/8 tics= 4096kHz 8bitoverflow= 16Hz</span>00129 <span class="comment">// 3 = CLOCK/32 tics= 1024kHz 8bitoverflow= 4Hz</span>00130 <span class="comment">// 4 = CLOCK/64 tics= 512Hz 8bitoverflow= 2Hz</span>00131 <span class="comment">// 5 = CLOCK/128 tics= 256Hz 8bitoverflow= 1Hz</span>00132 <span class="comment">// 6 = CLOCK/256 tics= 128Hz 8bitoverflow= 0.5Hz</span>00133 <span class="comment">// 7 = CLOCK/1024 tics= 32Hz 8bitoverflow= 0.125Hz</span>00134 <a name="l00135"></a><a class="code" href="group__timerx8.html#ga15">00135</a> <span class="preprocessor">#define TIMER_CLK_STOP 0x00 </span><span class="comment">///< Timer Stopped</span><a name="l00136"></a><a class="code" href="group__timerx8.html#ga16">00136</a> <span class="comment"></span>#define TIMER_CLK_DIV1 0x01 <span class="comment">///< Timer clocked at F_CPU</span><a name="l00137"></a><a class="code" href="group__timerx8.html#ga17">00137</a> <span class="comment"></span>#define TIMER_CLK_DIV8 0x02 <span class="comment">///< Timer clocked at F_CPU/8</span><a name="l00138"></a><a class="code" href="group__timerx8.html#ga18">00138</a> <span class="comment"></span>#define TIMER_CLK_DIV64 0x03 <span class="comment">///< Timer clocked at F_CPU/64</span><a name="l00139"></a><a class="code" href="group__timerx8.html#ga19">00139</a> <span class="comment"></span>#define TIMER_CLK_DIV256 0x04 <span class="comment">///< Timer clocked at F_CPU/256</span><a name="l00140"></a><a class="code" href="group__timerx8.html#ga20">00140</a> <span class="comment"></span>#define TIMER_CLK_DIV1024 0x05 <span class="comment">///< Timer clocked at F_CPU/1024</span><a name="l00141"></a><a class="code" href="group__timerx8.html#ga21">00141</a> <span class="comment"></span>#define TIMER_CLK_T_FALL 0x06 <span class="comment">///< Timer clocked at T falling edge</span><a name="l00142"></a><a class="code" href="group__timerx8.html#ga22">00142</a> <span class="comment"></span>#define TIMER_CLK_T_RISE 0x07 <span class="comment">///< Timer clocked at T rising edge</span><a name="l00143"></a><a class="code" href="group__timerx8.html#ga23">00143</a> <span class="comment"></span>#define TIMER_PRESCALE_MASK 0x07 <span class="comment">///< Timer Prescaler Bit-Mask</span>00144 <span class="comment"></span><a name="l00145"></a><a class="code" href="group__timerx8.html#ga24">00145</a> <span class="preprocessor">#define TIMERRTC_CLK_STOP 0x00 </span><span class="comment">///< RTC Timer Stopped</span><a name="l00146"></a><a class="code" href="group__timerx8.html#ga25">00146</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV1 0x01 <span class="comment">///< RTC Timer clocked at F_CPU</span><a name="l00147"></a><a class="code" href="group__timerx8.html#ga26">00147</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV8 0x02 <span class="comment">///< RTC Timer clocked at F_CPU/8</span><a name="l00148"></a><a class="code" href="group__timerx8.html#ga27">00148</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV32 0x03 <span class="comment">///< RTC Timer clocked at F_CPU/32</span><a name="l00149"></a><a class="code" href="group__timerx8.html#ga28">00149</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV64 0x04 <span class="comment">///< RTC Timer clocked at F_CPU/64</span><a name="l00150"></a><a class="code" href="group__timerx8.html#ga29">00150</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV128 0x05 <span class="comment">///< RTC Timer clocked at F_CPU/128</span><a name="l00151"></a><a class="code" href="group__timerx8.html#ga30">00151</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV256 0x06 <span class="comment">///< RTC Timer clocked at F_CPU/256</span><a name="l00152"></a><a class="code" href="group__timerx8.html#ga31">00152</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV1024 0x07 <span class="comment">///< RTC Timer clocked at F_CPU/1024</span><a name="l00153"></a><a class="code" href="group__timerx8.html#ga32">00153</a> <span class="comment"></span>#define TIMERRTC_PRESCALE_MASK 0x07 <span class="comment">///< RTC Timer Prescaler Bit-Mask</span>00154 <span class="comment"></span>00155 <span class="comment">// default prescale settings for the timers</span>00156 <span class="comment">// these settings are applied when you call</span>00157 <span class="comment">// timerInit or any of the timer<x>Init</span><a name="l00158"></a><a class="code" href="group__timerx8.html#ga33">00158</a> <span class="preprocessor">#define TIMER0PRESCALE TIMER_CLK_DIV8 </span><span class="comment">///< timer 0 prescaler default</span><a name="l00159"></a><a class="code" href="group__timerx8.html#ga34">00159</a> <span class="comment"></span>#define TIMER1PRESCALE TIMER_CLK_DIV64 <span class="comment">///< timer 1 prescaler default</span><a name="l00160"></a><a class="code" href="group__timerx8.html#ga35">00160</a> <span class="comment"></span>#define TIMER2PRESCALE TIMERRTC_CLK_DIV64 <span class="comment">///< timer 2 prescaler default</span>00161 <span class="comment"></span>00162 <span class="comment">// interrupt macros for attaching user functions to timer interrupts</span>00163 <span class="comment">// use these with timerAttach( intNum, function )</span>00164 <span class="preprocessor">#define TIMER0OVERFLOW_INT 0</span>00165 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OVERFLOW_INT 1</span>00166 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREA_INT 2</span>00167 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREB_INT 3</span>00168 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1INPUTCAPTURE_INT 4</span>00169 <span class="preprocessor"></span><span class="preprocessor">#define TIMER2OVERFLOW_INT 5</span>00170 <span class="preprocessor"></span><span class="preprocessor">#define TIMER2OUTCOMPARE_INT 6</span>00171 <span class="preprocessor"></span><span class="preprocessor">#ifdef OCR0 // for processors that support output compare on Timer0</span>00172 <span class="preprocessor"></span><span class="preprocessor">#define TIMER0OUTCOMPARE_INT 7</span>00173 <span class="preprocessor"></span><span class="preprocessor">#define TIMER_NUM_INTERRUPTS 8</span>00174 <span class="preprocessor"></span><span class="preprocessor">#else</span>00175 <span class="preprocessor"></span><span class="preprocessor">#define TIMER_NUM_INTERRUPTS 7</span>00176 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00177 <span class="preprocessor"></span>00178 <span class="comment">// default type of interrupt handler to use for timers</span>00179 <span class="comment">// *do not change unless you know what you're doing</span>00180 <span class="comment">// Value may be SIGNAL or INTERRUPT</span>00181 <span class="preprocessor">#ifndef TIMER_INTERRUPT_HANDLER</span>00182 <span class="preprocessor"></span><span class="preprocessor">#define TIMER_INTERRUPT_HANDLER SIGNAL</span>00183 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00184 <span class="preprocessor"></span>00185 <span class="comment">// functions</span>00186 <span class="preprocessor">#define delay delay_us</span>00187 <span class="preprocessor"></span><span class="preprocessor">#define delay_ms timerPause</span>00188 <span class="preprocessor"></span><span class="keywordtype">void</span> delay_us(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> time_us);00189 <span class="comment"></span>00190 <span class="comment">//! initializes timing system (all timers)</span>00191 <span class="comment"></span><span class="comment">// runs all timer init functions</span>00192 <span class="comment">// sets all timers to default prescale values #defined in systimer.c</span>00193 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga1">timerInit</a>(<span class="keywordtype">void</span>);00194 00195 <span class="comment">// default initialization routines for each timer</span>00196 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga2">timer0Init</a>(<span class="keywordtype">void</span>); <span class="comment">///< initialize timer0</span>00197 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga3">timer1Init</a>(<span class="keywordtype">void</span>); <span class="comment">///< initialize timer1</span>00198 <span class="comment"></span><span class="preprocessor">#ifdef TCNT2 // support timer2 only if it exists</span>00199 <span class="preprocessor"></span><span class="keywordtype">void</span> timer2Init(<span class="keywordtype">void</span>); <span class="comment">///< initialize timer2</span>00200 <span class="comment"></span><span class="preprocessor">#endif</span>00201 <span class="preprocessor"></span>00202 <span class="comment">// Clock prescaler set/get commands for each timer/counter</span>00203 <span class="comment">// For setting the prescaler, you should use one of the #defines</span>00204 <span class="comment">// above like TIMER_CLK_DIVx, where [x] is the division rate</span>00205 <span class="comment">// you want.</span>00206 <span class="comment">// When getting the current prescaler setting, the return value</span>00207 <span class="comment">// will be the [x] division value currently set.</span>00208 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga4">timer0SetPrescaler</a>(u08 prescale); <span class="comment">///< set timer0 prescaler</span>00209 <span class="comment"></span>u16 <a class="code" href="group__timer.html#ga5">timer0GetPrescaler</a>(<span class="keywordtype">void</span>); <span class="comment">///< get timer0 prescaler</span>00210 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga6">timer1SetPrescaler</a>(u08 prescale); <span class="comment">///< set timer1 prescaler</span>00211 <span class="comment"></span>u16 <a class="code" href="group__timer.html#ga7">timer1GetPrescaler</a>(<span class="keywordtype">void</span>); <span class="comment">///< get timer0 prescaler</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -