Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
||
3 | <title>Procyon AVRlib: timer128.h Source File</title> |
||
4 | <link href="dox.css" rel="stylesheet" type="text/css"> |
||
5 | </head><body> |
||
6 | <!-- Generated by Doxygen 1.4.2 --> |
||
7 | <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
||
8 | <h1>timer128.h</h1><a href="timer128_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file timer128.h \brief System Timer function library for Mega128. */</span> |
||
9 | 00002 <span class="comment">//*****************************************************************************</span> |
||
10 | 00003 <span class="comment">//</span> |
||
11 | 00004 <span class="comment">// File Name : 'timer128.h'</span> |
||
12 | 00005 <span class="comment">// Title : System Timer function library for Mega128</span> |
||
13 | 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2000-2003</span> |
||
14 | 00007 <span class="comment">// Created : 11/22/2000</span> |
||
15 | 00008 <span class="comment">// Revised : 02/10/2003</span> |
||
16 | 00009 <span class="comment">// Version : 1.1</span> |
||
17 | 00010 <span class="comment">// Target MCU : Atmel AVR Series</span> |
||
18 | 00011 <span class="comment">// Editor Tabs : 4</span> |
||
19 | 00012 <span class="comment">//</span> |
||
20 | 00013 <span class="comment">// This code is distributed under the GNU Public License</span> |
||
21 | 00014 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span> |
||
22 | 00015 <span class="comment">//</span><span class="comment"></span> |
||
23 | 00016 <span class="comment">/// \ingroup driver_avr</span> |
||
24 | 00017 <span class="comment">/// \defgroup timer128 Timer Function Library for ATmega128 (timer128.c)</span> |
||
25 | 00018 <span class="comment">/// \code #include "timer128.h" \endcode</span> |
||
26 | 00019 <span class="comment">/// \par Overview</span> |
||
27 | 00020 <span class="comment">/// This library provides functions for use with the timers internal to the</span> |
||
28 | 00021 <span class="comment">/// AVR ATmega128. Functions include initialization, set prescaler,</span> |
||
29 | 00022 <span class="comment">/// calibrated pause function (in milliseconds), attaching and detaching</span> |
||
30 | 00023 <span class="comment">/// of user functions to interrupts, overflow counters, and PWM.</span> |
||
31 | 00024 <span class="comment">///</span> |
||
32 | 00025 <span class="comment">/// \par About Timers</span> |
||
33 | 00026 <span class="comment">/// The Atmel AVR-series processors each contain at least one</span> |
||
34 | 00027 <span class="comment">/// hardware timer/counter. Many of the processors contain 2 or 3</span> |
||
35 | 00028 <span class="comment">/// timers. Generally speaking, a timer is a hardware counter inside</span> |
||
36 | 00029 <span class="comment">/// the processor which counts at a rate related to the main CPU clock</span> |
||
37 | 00030 <span class="comment">/// frequency. Because the counter value increasing (counting up) at</span> |
||
38 | 00031 <span class="comment">/// a precise rate, we can use it as a timer to create or measure </span> |
||
39 | 00032 <span class="comment">/// precise delays, schedule events, or generate signals of a certain</span> |
||
40 | 00033 <span class="comment">/// frequency or pulse-width.</span> |
||
41 | 00034 <span class="comment">/// \par</span> |
||
42 | 00035 <span class="comment">/// As an example, the ATmega163 processor has 3 timer/counters.</span> |
||
43 | 00036 <span class="comment">/// Timer0, Timer1, and Timer2 are 8, 16, and 8 bits wide respectively.</span> |
||
44 | 00037 <span class="comment">/// This means that they overflow, or roll over back to zero, at a</span> |
||
45 | 00038 <span class="comment">/// count value of 256 for 8bits or 65536 for 16bits. A prescaler is</span> |
||
46 | 00039 <span class="comment">/// avaiable for each timer, and the prescaler allows you to pre-divide</span> |
||
47 | 00040 <span class="comment">/// the main CPU clock rate down to a slower speed before feeding it to</span> |
||
48 | 00041 <span class="comment">/// the counting input of a timer. For example, if the CPU clock</span> |
||
49 | 00042 <span class="comment">/// frequency is 3.69MHz, and Timer0's prescaler is set to divide-by-8,</span> |
||
50 | 00043 <span class="comment">/// then Timer0 will "tic" at 3690000/8 = 461250Hz. Because Timer0 is</span> |
||
51 | 00044 <span class="comment">/// an 8bit timer, it will count to 256 in just 256/461250Hz = 0.555ms.</span> |
||
52 | 00045 <span class="comment">/// In fact, when it hits 255, it will overflow and start again at</span> |
||
53 | 00046 <span class="comment">/// zero. In this case, Timer0 will overflow 461250/256 = 1801.76</span> |
||
54 | 00047 <span class="comment">/// times per second.</span> |
||
55 | 00048 <span class="comment">/// \par</span> |
||
56 | 00049 <span class="comment">/// Timer0 can be used a number of ways simultaneously. First, the</span> |
||
57 | 00050 <span class="comment">/// value of the timer can be read by accessing the CPU register \c TCNT0.</span> |
||
58 | 00051 <span class="comment">/// We could, for example, figure out how long it takes to execute a</span> |
||
59 | 00052 <span class="comment">/// C command by recording the value of \c TCNT0 before and after</span> |
||
60 | 00053 <span class="comment">/// execution, then subtract (after-before) = time elapsed. Or we can</span> |
||
61 | 00054 <span class="comment">/// enable the overflow interrupt which goes off every time T0</span> |
||
62 | 00055 <span class="comment">/// overflows and count out longer delays (multiple overflows), or</span> |
||
63 | 00056 <span class="comment">/// execute a special periodic function at every overflow.</span> |
||
64 | 00057 <span class="comment">/// \par</span> |
||
65 | 00058 <span class="comment">/// The other timers (Timer1 and Timer2) offer all the abilities of</span> |
||
66 | 00059 <span class="comment">/// Timer0 and many more features. Both T1 and T2 can operate as</span> |
||
67 | 00060 <span class="comment">/// general-purpose timers, but T1 has special hardware allowing it to</span> |
||
68 | 00061 <span class="comment">/// generate PWM signals, while T2 is specially designed to help count</span> |
||
69 | 00062 <span class="comment">/// out real time (like hours, minutes, seconds). See the</span> |
||
70 | 00063 <span class="comment">/// Timer/Counter section of the processor datasheet for more info.</span> |
||
71 | 00064 <span class="comment">///</span> |
||
72 | 00065 <span class="comment"></span><span class="comment">//*****************************************************************************</span><span class="comment"></span> |
||
73 | 00066 <span class="comment">//@{</span> |
||
74 | 00067 <span class="comment"></span> |
||
75 | 00068 <span class="preprocessor">#ifndef TIMER128_H</span> |
||
76 | 00069 <span class="preprocessor"></span><span class="preprocessor">#define TIMER128_H</span> |
||
77 | 00070 <span class="preprocessor"></span> |
||
78 | 00071 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> |
||
79 | 00072 |
||
80 | 00073 <span class="comment">// constants/macros/typdefs</span> |
||
81 | 00074 |
||
82 | 00075 <span class="comment">// Timer/clock prescaler values and timer overflow rates</span> |
||
83 | 00076 <span class="comment">// tics = rate at which the timer counts up</span> |
||
84 | 00077 <span class="comment">// 8bitoverflow = rate at which the timer overflows 8bits (or reaches 256)</span> |
||
85 | 00078 <span class="comment">// 16bit [overflow] = rate at which the timer overflows 16bits (65536)</span> |
||
86 | 00079 <span class="comment">// </span> |
||
87 | 00080 <span class="comment">// overflows can be used to generate periodic interrupts</span> |
||
88 | 00081 <span class="comment">//</span> |
||
89 | 00082 <span class="comment">// for 8MHz crystal</span> |
||
90 | 00083 <span class="comment">// 0 = STOP (Timer not counting)</span> |
||
91 | 00084 <span class="comment">// 1 = CLOCK tics= 8MHz 8bitoverflow= 31250Hz 16bit= 122.070Hz</span> |
||
92 | 00085 <span class="comment">// 2 = CLOCK/8 tics= 1MHz 8bitoverflow= 3906.25Hz 16bit= 15.259Hz</span> |
||
93 | 00086 <span class="comment">// 3 = CLOCK/64 tics= 125kHz 8bitoverflow= 488.28Hz 16bit= 1.907Hz</span> |
||
94 | 00087 <span class="comment">// 4 = CLOCK/256 tics= 31250Hz 8bitoverflow= 122.07Hz 16bit= 0.477Hz</span> |
||
95 | 00088 <span class="comment">// 5 = CLOCK/1024 tics= 7812.5Hz 8bitoverflow= 30.52Hz 16bit= 0.119Hz</span> |
||
96 | 00089 <span class="comment">// 6 = External Clock on T(x) pin (falling edge)</span> |
||
97 | 00090 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span> |
||
98 | 00091 |
||
99 | 00092 <span class="comment">// for 4MHz crystal</span> |
||
100 | 00093 <span class="comment">// 0 = STOP (Timer not counting)</span> |
||
101 | 00094 <span class="comment">// 1 = CLOCK tics= 4MHz 8bitoverflow= 15625Hz 16bit= 61.035Hz</span> |
||
102 | 00095 <span class="comment">// 2 = CLOCK/8 tics= 500kHz 8bitoverflow= 1953.125Hz 16bit= 7.629Hz</span> |
||
103 | 00096 <span class="comment">// 3 = CLOCK/64 tics= 62500Hz 8bitoverflow= 244.141Hz 16bit= 0.954Hz</span> |
||
104 | 00097 <span class="comment">// 4 = CLOCK/256 tics= 15625Hz 8bitoverflow= 61.035Hz 16bit= 0.238Hz</span> |
||
105 | 00098 <span class="comment">// 5 = CLOCK/1024 tics= 3906.25Hz 8bitoverflow= 15.259Hz 16bit= 0.060Hz</span> |
||
106 | 00099 <span class="comment">// 6 = External Clock on T(x) pin (falling edge)</span> |
||
107 | 00100 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span> |
||
108 | 00101 |
||
109 | 00102 <span class="comment">// for 3.69MHz crystal</span> |
||
110 | 00103 <span class="comment">// 0 = STOP (Timer not counting)</span> |
||
111 | 00104 <span class="comment">// 1 = CLOCK tics= 3.69MHz 8bitoverflow= 14414Hz 16bit= 56.304Hz</span> |
||
112 | 00105 <span class="comment">// 2 = CLOCK/8 tics= 461250Hz 8bitoverflow= 1801.758Hz 16bit= 7.038Hz</span> |
||
113 | 00106 <span class="comment">// 3 = CLOCK/64 tics= 57625.25Hz 8bitoverflow= 225.220Hz 16bit= 0.880Hz</span> |
||
114 | 00107 <span class="comment">// 4 = CLOCK/256 tics= 14414.063Hz 8bitoverflow= 56.305Hz 16bit= 0.220Hz</span> |
||
115 | 00108 <span class="comment">// 5 = CLOCK/1024 tics= 3603.516Hz 8bitoverflow= 14.076Hz 16bit= 0.055Hz</span> |
||
116 | 00109 <span class="comment">// 6 = External Clock on T(x) pin (falling edge)</span> |
||
117 | 00110 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span> |
||
118 | 00111 |
||
119 | 00112 <span class="comment">// for 32.768KHz crystal on timer 2 (use for real-time clock)</span> |
||
120 | 00113 <span class="comment">// 0 = STOP</span> |
||
121 | 00114 <span class="comment">// 1 = CLOCK tics= 32.768kHz 8bitoverflow= 128Hz</span> |
||
122 | 00115 <span class="comment">// 2 = CLOCK/8 tics= 4096kHz 8bitoverflow= 16Hz</span> |
||
123 | 00116 <span class="comment">// 3 = CLOCK/64 tics= 512Hz 8bitoverflow= 2Hz</span> |
||
124 | 00117 <span class="comment">// 4 = CLOCK/256 tics= 128Hz 8bitoverflow= 0.5Hz</span> |
||
125 | 00118 <span class="comment">// 5 = CLOCK/1024 tics= 32Hz 8bitoverflow= 0.125Hz</span> |
||
126 | 00119 |
||
127 | <a name="l00120"></a><a class="code" href="group__timer128.html#ga45">00120</a> <span class="preprocessor">#define TIMER_CLK_STOP 0x00 </span><span class="comment">///< Timer Stopped</span> |
||
128 | <a name="l00121"></a><a class="code" href="group__timer128.html#ga46">00121</a> <span class="comment"></span>#define TIMER_CLK_DIV1 0x01 <span class="comment">///< Timer clocked at F_CPU</span> |
||
129 | <a name="l00122"></a><a class="code" href="group__timer128.html#ga47">00122</a> <span class="comment"></span>#define TIMER_CLK_DIV8 0x02 <span class="comment">///< Timer clocked at F_CPU/8</span> |
||
130 | <a name="l00123"></a><a class="code" href="group__timer128.html#ga48">00123</a> <span class="comment"></span>#define TIMER_CLK_DIV64 0x03 <span class="comment">///< Timer clocked at F_CPU/64</span> |
||
131 | <a name="l00124"></a><a class="code" href="group__timer128.html#ga49">00124</a> <span class="comment"></span>#define TIMER_CLK_DIV256 0x04 <span class="comment">///< Timer clocked at F_CPU/256</span> |
||
132 | <a name="l00125"></a><a class="code" href="group__timer128.html#ga50">00125</a> <span class="comment"></span>#define TIMER_CLK_DIV1024 0x05 <span class="comment">///< Timer clocked at F_CPU/1024</span> |
||
133 | <a name="l00126"></a><a class="code" href="group__timer128.html#ga51">00126</a> <span class="comment"></span>#define TIMER_CLK_T_FALL 0x06 <span class="comment">///< Timer clocked at T falling edge</span> |
||
134 | <a name="l00127"></a><a class="code" href="group__timer128.html#ga52">00127</a> <span class="comment"></span>#define TIMER_CLK_T_RISE 0x07 <span class="comment">///< Timer clocked at T rising edge</span> |
||
135 | <a name="l00128"></a><a class="code" href="group__timer128.html#ga53">00128</a> <span class="comment"></span>#define TIMER_PRESCALE_MASK 0x07 <span class="comment">///< Timer Prescaler Bit-Mask</span> |
||
136 | 00129 <span class="comment"></span> |
||
137 | <a name="l00130"></a><a class="code" href="group__timer128.html#ga54">00130</a> <span class="preprocessor">#define TIMERRTC_CLK_STOP 0x00 </span><span class="comment">///< RTC Timer Stopped</span> |
||
138 | <a name="l00131"></a><a class="code" href="group__timer128.html#ga55">00131</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV1 0x01 <span class="comment">///< RTC Timer clocked at F_CPU</span> |
||
139 | <a name="l00132"></a><a class="code" href="group__timer128.html#ga56">00132</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV8 0x02 <span class="comment">///< RTC Timer clocked at F_CPU/8</span> |
||
140 | <a name="l00133"></a><a class="code" href="group__timer128.html#ga57">00133</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV32 0x03 <span class="comment">///< RTC Timer clocked at F_CPU/32</span> |
||
141 | <a name="l00134"></a><a class="code" href="group__timer128.html#ga58">00134</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV64 0x04 <span class="comment">///< RTC Timer clocked at F_CPU/64</span> |
||
142 | <a name="l00135"></a><a class="code" href="group__timer128.html#ga59">00135</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV128 0x05 <span class="comment">///< RTC Timer clocked at F_CPU/128</span> |
||
143 | <a name="l00136"></a><a class="code" href="group__timer128.html#ga60">00136</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV256 0x06 <span class="comment">///< RTC Timer clocked at F_CPU/256</span> |
||
144 | <a name="l00137"></a><a class="code" href="group__timer128.html#ga61">00137</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV1024 0x07 <span class="comment">///< RTC Timer clocked at F_CPU/1024</span> |
||
145 | <a name="l00138"></a><a class="code" href="group__timer128.html#ga62">00138</a> <span class="comment"></span>#define TIMERRTC_PRESCALE_MASK 0x07 <span class="comment">///< RTC Timer Prescaler Bit-Mask</span> |
||
146 | 00139 <span class="comment"></span> |
||
147 | 00140 <span class="comment">// default prescale settings for the timers</span> |
||
148 | 00141 <span class="comment">// these settings are applied when you call</span> |
||
149 | 00142 <span class="comment">// timerInit or any of the timer<x>Init</span> |
||
150 | <a name="l00143"></a><a class="code" href="group__timer128.html#ga63">00143</a> <span class="preprocessor">#define TIMER0PRESCALE TIMERRTC_CLK_DIV64 </span><span class="comment">///< timer 0 prescaler default</span> |
||
151 | <a name="l00144"></a><a class="code" href="group__timer128.html#ga64">00144</a> <span class="comment"></span>#define TIMER1PRESCALE TIMER_CLK_DIV64 <span class="comment">///< timer 1 prescaler default</span> |
||
152 | <a name="l00145"></a><a class="code" href="group__timer128.html#ga65">00145</a> <span class="comment"></span>#define TIMER2PRESCALE TIMER_CLK_DIV8 <span class="comment">///< timer 2 prescaler default</span> |
||
153 | <a name="l00146"></a><a class="code" href="group__timer128.html#ga66">00146</a> <span class="comment"></span>#define TIMER3PRESCALE TIMER_CLK_DIV64 <span class="comment">///< timer 3 prescaler default</span> |
||
154 | 00147 <span class="comment"></span> |
||
155 | 00148 <span class="comment">// interrupt macros for attaching user functions to timer interrupts</span> |
||
156 | 00149 <span class="comment">// use these with timerAttach( intNum, function )</span> |
||
157 | 00150 <span class="comment">// timer 0</span> |
||
158 | 00151 <span class="preprocessor">#define TIMER0OVERFLOW_INT 0</span> |
||
159 | 00152 <span class="preprocessor"></span><span class="preprocessor">#define TIMER0OUTCOMPARE_INT 1</span> |
||
160 | 00153 <span class="preprocessor"></span><span class="comment">// timer 1</span> |
||
161 | 00154 <span class="preprocessor">#define TIMER1OVERFLOW_INT 2</span> |
||
162 | 00155 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREA_INT 3</span> |
||
163 | 00156 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREB_INT 4</span> |
||
164 | 00157 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREC_INT 5</span> |
||
165 | 00158 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1INPUTCAPTURE_INT 6</span> |
||
166 | 00159 <span class="preprocessor"></span><span class="comment">// timer 2</span> |
||
167 | 00160 <span class="preprocessor">#define TIMER2OVERFLOW_INT 7</span> |
||
168 | 00161 <span class="preprocessor"></span><span class="preprocessor">#define TIMER2OUTCOMPARE_INT 8</span> |
||
169 | 00162 <span class="preprocessor"></span><span class="comment">// timer 3</span> |
||
170 | 00163 <span class="preprocessor">#define TIMER3OVERFLOW_INT 9</span> |
||
171 | 00164 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3OUTCOMPAREA_INT 10</span> |
||
172 | 00165 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3OUTCOMPAREB_INT 11</span> |
||
173 | 00166 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3OUTCOMPAREC_INT 12</span> |
||
174 | 00167 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3INPUTCAPTURE_INT 13</span> |
||
175 | 00168 <span class="preprocessor"></span> |
||
176 | 00169 <span class="preprocessor">#define TIMER_NUM_INTERRUPTS 14</span> |
||
177 | 00170 <span class="preprocessor"></span> |
||
178 | 00171 <span class="comment">// type of interrupt handler to use for timers</span> |
||
179 | 00172 <span class="comment">// *do not change unless you know what you're doing</span> |
||
180 | 00173 <span class="comment">// Value may be SIGNAL or INTERRUPT</span> |
||
181 | 00174 <span class="preprocessor">#ifndef TIMER_INTERRUPT_HANDLER</span> |
||
182 | 00175 <span class="preprocessor"></span><span class="preprocessor">#define TIMER_INTERRUPT_HANDLER SIGNAL</span> |
||
183 | 00176 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
||
184 | 00177 <span class="preprocessor"></span> |
||
185 | 00178 <span class="comment">// functions</span> |
||
186 | 00179 <span class="preprocessor">#define delay delay_us</span> |
||
187 | 00180 <span class="preprocessor"></span><span class="preprocessor">#define delay_ms timerPause</span> |
||
188 | 00181 <span class="preprocessor"></span><span class="keywordtype">void</span> delay_us(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> time_us); |
||
189 | 00182 |
||
190 | 00183 <span class="comment">// initializes timing system</span> |
||
191 | 00184 <span class="comment">// runs all timer init functions</span> |
||
192 | 00185 <span class="comment">// sets all timers to default prescale values #defined in systimer.c</span> |
||
193 | 00186 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga1">timerInit</a>(<span class="keywordtype">void</span>); |
||
194 | 00187 |
||
195 | 00188 <span class="comment">// default initialization routines for each timer</span> |
||
196 | 00189 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga2">timer0Init</a>(<span class="keywordtype">void</span>); |
||
197 | 00190 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga3">timer1Init</a>(<span class="keywordtype">void</span>); |
||
198 | 00191 <span class="keywordtype">void</span> timer2Init(<span class="keywordtype">void</span>); |
||
199 | 00192 <span class="keywordtype">void</span> timer3Init(<span class="keywordtype">void</span>); |
||
200 | 00193 |
||
201 | 00194 <span class="comment">// Clock prescaler set/get commands for each timer/counter</span> |
||
202 | 00195 <span class="comment">// For setting the prescaler, you should use one of the #defines</span> |
||
203 | 00196 <span class="comment">// above like TIMER_CLK_DIVx, where [x] is the division rate</span> |
||
204 | 00197 <span class="comment">// you want.</span> |
||
205 | 00198 <span class="comment">// When getting the current prescaler setting, the return value</span> |
||
206 | 00199 <span class="comment">// will be the [x] division value currently set.</span> |
||
207 | 00200 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga4">timer0SetPrescaler</a>(u08 prescale); <span class="comment">///< set timer0 prescaler division index</span> |
||
208 | 00201 <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 division index</span> |
||
209 | 00202 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga8">timer2SetPrescaler</a>(u08 prescale); <span class="comment">///< set timer2 prescaler division index</span> |
||
210 | 00203 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga9">timer3SetPrescaler</a>(u08 prescale); <span class="comment">///< set timer3 prescaler division index</span> |
||
211 | 00204 <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 division rate</span> |
||
212 | 00205 <span class="comment"></span>u16 <a class="code" href="group__timer.html#ga7">timer1GetPrescaler</a>(<span class="keywordtype">void</span>); <span class="comment">///< get timer1 prescaler division rate</span> |
||
213 | 00206 <span class="comment"></span>u16 <a class="code" href="group__timer128.html#ga12">timer2GetPrescaler</a>(<span class="keywordtype">void</span>); <span class="comment">///< get timer2 prescaler division rate</span> |
||
214 | 00207 <span class="comment"></span>u16 <a class="code" href="group__timer128.html#ga13">timer3GetPrescaler</a>(<span class="keywordtype">void</span>); <span class="comment">///< get timer3 prescaler division rate</span> |
||
215 | 00208 <span class="comment"></span> |
||
216 | 00209 |
||
217 | 00210 <span class="comment">// TimerAttach and Detach commands</span> |
||
218 | 00211 <span class="comment">// These functions allow the attachment (or detachment) of any user function</span> |
||
219 | 00212 <span class="comment">// to a timer interrupt. "Attaching" one of your own functions to a timer</span> |
||
220 | 00213 <span class="comment">// interrupt means that it will be called whenever that interrupt happens.</span> |
||
221 | 00214 <span class="comment">// Using attach is better than rewriting the actual INTERRUPT() function</span> |
||
222 | 00215 <span class="comment">// because your code will still work and be compatible if the timer library</span> |
||
223 | 00216 <span class="comment">// is updated. Also, using Attach allows your code and any predefined timer</span> |
||
224 | 00217 <span class="comment">// code to work together and at the same time. (ie. "attaching" your own</span> |
||
225 | 00218 <span class="comment">// function to the timer0 overflow doesn't prevent timerPause from working,</span> |
||
226 | 00219 <span class="comment">// but rather allows you to share the interrupt.)</span> |
||
227 | 00220 <span class="comment">//</span> |
||
228 | 00221 <span class="comment">// timerAttach(TIMER1OVERFLOW_INT, myOverflowFunction);</span> |
||
229 | 00222 <span class="comment">// timerDetach(TIMER1OVERFLOW_INT)</span> |
||
230 | 00223 <span class="comment">//</span> |
||
231 | 00224 <span class="comment">// timerAttach causes the myOverflowFunction() to be attached, and therefore</span> |
||
232 | 00225 <span class="comment">// execute, whenever an overflow on timer1 occurs. timerDetach removes the</span> |
||
233 | 00226 <span class="comment">// association and executes no user function when the interrupt occurs.</span> |
||
234 | 00227 <span class="comment">// myOverflowFunction must be defined with no return value and no arguments:</span> |
||
235 | 00228 <span class="comment">//</span> |
||
236 | 00229 <span class="comment">// void myOverflowFunction(void) { ... }</span> |
||
237 | 00230 |
||
238 | 00231 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga8">timerAttach</a>(u08 interruptNum, <span class="keywordtype">void</span> (*userFunc)(<span class="keywordtype">void</span>) ); |
||
239 | 00232 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga9">timerDetach</a>(u08 interruptNum); |
||
240 | 00233 |
||
241 | 00234 |
||
242 | 00235 <span class="comment">// timing commands</span> |
||
243 | 00236 <span class="comment">// timerPause pauses for the number of milliseconds specified in <pause_ms></span> |
||
244 | 00237 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga10">timerPause</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> pause_ms); |
||
245 | 00238 |
||
246 | 00239 <span class="comment">// overflow counters</span> |
||
247 | 00240 <span class="comment">// to be documented</span> |
||
248 | 00241 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga11">timer0ClearOverflowCount</a>(<span class="keywordtype">void</span>); |
||
249 | 00242 <span class="keywordtype">long</span> <a class="code" href="group__timer.html#ga12">timer0GetOverflowCount</a>(<span class="keywordtype">void</span>); |
||
250 | 00243 <span class="keywordtype">void</span> timer2ClearOverflowCount(<span class="keywordtype">void</span>); |
||
251 | 00244 <span class="keywordtype">long</span> timer2GetOverflowCount(<span class="keywordtype">void</span>); |
||
252 | 00245 |
||
253 | 00246 <span class="comment">// PWM initialization and set commands for timerX (where X is either 1 or 3)</span> |
||
254 | 00247 <span class="comment">// timerXPWMInit()</span> |
||
255 | 00248 <span class="comment">// configures the timerX hardware for PWM mode on pins OCXA, OCXB, and OCXC.</span> |
||
256 | 00249 <span class="comment">// bitRes should be 8,9,or 10 for 8,9,or 10bit PWM resolution</span> |
||
257 | 00250 <span class="comment">//</span> |
||
258 | 00251 <span class="comment">// timerXPWMOff()</span> |
||
259 | 00252 <span class="comment">// turns off all timerX PWM output and set timer mode to normal state</span> |
||
260 | 00253 <span class="comment">//</span> |
||
261 | 00254 <span class="comment">// timerXPWMAOn(), timerXPWMBOn(), timerXPWMCOn()</span> |
||
262 | 00255 <span class="comment">// turn on output of PWM signals to OCXA,B,C pins</span> |
||
263 | 00256 <span class="comment">// NOTE: Until you define the OCXA,B,C pins as outputs, and run</span> |
||
264 | 00257 <span class="comment">// this "on" command, no PWM output will be output</span> |
||
265 | 00258 <span class="comment">//</span> |
||
266 | 00259 <span class="comment">// timerXPWMAOff(), timerXPWMBOff(), timerXPWMCOff()</span> |
||
267 | 00260 <span class="comment">// turn off output of PWM signals to OCXA,B,C pins</span> |
||
268 | 00261 <span class="comment">//</span> |
||
269 | 00262 <span class="comment">// timerXPWMASet(), timer1PWMBSet(), timerXPWMCSet()</span> |
||
270 | 00263 <span class="comment">// sets the PWM duty cycle for each channel</span> |
||
271 | 00264 <span class="comment">// NOTE: <pwmDuty> should be in the range 0-255 for 8bit PWM</span> |
||
272 | 00265 <span class="comment">// <pwmDuty> should be in the range 0-511 for 9bit PWM</span> |
||
273 | 00266 <span class="comment">// <pwmDuty> should be in the range 0-1023 for 10bit PWM</span> |
||
274 | 00267 <span class="comment">// NOTE: the PWM frequency can be controlled in increments by setting the</span> |
||
275 | 00268 <span class="comment">// prescaler for timer1</span> |
||
276 | 00269 |
||
277 | 00270 <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga0">timer1PWMInit</a>(u08 bitRes); <span class="comment">///< initialize and set timer1 mode to PWM</span> |
||
278 | 00271 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga1">timer1PWMInitICR</a>(u16 topcount);<span class="comment">///< initialize and set timer1 mode to PWM with specific top count</span> |
||
279 | 00272 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga2">timer1PWMOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off all timer1 PWM output and set timer mode to normal</span> |
||
280 | 00273 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga3">timer1PWMAOn</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn on timer1 Channel A (OC1A) PWM output</span> |
||
281 | 00274 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga4">timer1PWMBOn</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn on timer1 Channel B (OC1B) PWM output</span> |
||
282 | 00275 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga26">timer1PWMCOn</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn on timer1 Channel C (OC1C) PWM output</span> |
||
283 | 00276 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off timer1 Channel A (OC1A) PWM output</span> |
||
284 | 00277 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off timer1 Channel B (OC1B) PWM output</span> |
||
285 | 00278 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga29">timer1PWMCOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off timer1 Channel C (OC1C) PWM output</span> |
||
286 | 00279 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga7">timer1PWMASet</a>(u16 pwmDuty); <span class="comment">///< set duty of timer1 Channel A (OC1A) PWM output</span> |
||
287 | 00280 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga8">timer1PWMBSet</a>(u16 pwmDuty); <span class="comment">///< set duty of timer1 Channel B (OC1B) PWM output</span> |
||
288 | 00281 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga32">timer1PWMCSet</a>(u16 pwmDuty); <span class="comment">///< set duty of timer1 Channel C (OC1C) PWM output</span> |
||
289 | 00282 <span class="comment"></span> |
||
290 | 00283 <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga33">timer3PWMInit</a>(u08 bitRes); <span class="comment">///< initialize and set timer3 mode to PWM</span> |
||
291 | 00284 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga34">timer3PWMInitICR</a>(u16 topcount);<span class="comment">///< initialize and set timer3 mode to PWM with specific top count</span> |
||
292 | 00285 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga35">timer3PWMOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off all timer3 PWM output and set timer mode to normal</span> |
||
293 | 00286 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga36">timer3PWMAOn</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn on timer3 Channel A (OC3A) PWM output</span> |
||
294 | 00287 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga37">timer3PWMBOn</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn on timer3 Channel B (OC3B) PWM output</span> |
||
295 | 00288 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga38">timer3PWMCOn</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn on timer3 Channel C (OC3C) PWM output</span> |
||
296 | 00289 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga39">timer3PWMAOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off timer3 Channel A (OC3A) PWM output</span> |
||
297 | 00290 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga40">timer3PWMBOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off timer3 Channel B (OC3B) PWM output</span> |
||
298 | 00291 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga41">timer3PWMCOff</a>(<span class="keywordtype">void</span>); <span class="comment">///< turn off timer3 Channel C (OC3C) PWM output</span> |
||
299 | 00292 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga42">timer3PWMASet</a>(u16 pwmDuty); <span class="comment">///< set duty of timer3 Channel A (OC3A) PWM output</span> |
||
300 | 00293 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga43">timer3PWMBSet</a>(u16 pwmDuty); <span class="comment">///< set duty of timer3 Channel B (OC3B) PWM output</span> |
||
301 | 00294 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga44">timer3PWMCSet</a>(u16 pwmDuty); <span class="comment">///< set duty of timer3 Channel C (OC3C) PWM output</span> |
||
302 | 00295 <span class="comment"></span><span class="comment"></span> |
||
303 | 00296 <span class="comment">//@}</span> |
||
304 | 00297 <span class="comment"></span> |
||
305 | 00298 <span class="comment">// Pulse generation commands have been moved to the pulse.c library</span> |
||
306 | 00299 |
||
307 | 00300 <span class="preprocessor">#endif</span> |
||
308 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by |
||
309 | <a href="http://www.doxygen.org/index.html"> |
||
310 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
311 | </body> |
||
312 | </html> |
Powered by WebSVN v2.8.3