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.c 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.c</h1><a href="timer128_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file timer128.c \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.c'</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/24/2003</span> |
||
16 | 00009 <span class="comment">// Version : 1.2</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> |
||
23 | 00016 <span class="comment">//*****************************************************************************</span> |
||
24 | 00017 |
||
25 | 00018 <span class="preprocessor">#include <avr/io.h></span> |
||
26 | 00019 <span class="preprocessor">#include <avr/interrupt.h></span> |
||
27 | 00020 <span class="preprocessor">#include <avr/pgmspace.h></span> |
||
28 | 00021 <span class="preprocessor">#include <avr/sleep.h></span> |
||
29 | 00022 |
||
30 | 00023 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> |
||
31 | 00024 <span class="preprocessor">#include "<a class="code" href="timer128_8h.html">timer128.h</a>"</span> |
||
32 | 00025 |
||
33 | 00026 <span class="comment">// Program ROM constants</span> |
||
34 | 00027 <span class="comment">// the prescale division values stored in order of timer control register index</span> |
||
35 | 00028 <span class="comment">// STOP, CLK, CLK/8, CLK/64, CLK/256, CLK/1024</span> |
||
36 | 00029 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> __attribute__ ((progmem)) TimerPrescaleFactor[] = {0,1,8,64,256,1024}; |
||
37 | 00030 <span class="comment">// the prescale division values stored in order of timer control register index</span> |
||
38 | 00031 <span class="comment">// STOP, CLK, CLK/8, CLK/32, CLK/64, CLK/128, CLK/256, CLK/1024</span> |
||
39 | 00032 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> __attribute__ ((progmem)) TimerRTCPrescaleFactor[] = {0,1,8,32,64,128,256,1024}; |
||
40 | 00033 |
||
41 | 00034 <span class="comment">// Global variables</span> |
||
42 | 00035 <span class="comment">// time registers</span> |
||
43 | 00036 <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> TimerPauseReg; |
||
44 | 00037 <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Timer0Reg0; |
||
45 | 00038 <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Timer0Reg1; |
||
46 | 00039 <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Timer2Reg0; |
||
47 | 00040 <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Timer2Reg1; |
||
48 | 00041 |
||
49 | 00042 <span class="keyword">typedef</span> void (*voidFuncPtr)(void); |
||
50 | 00043 <span class="keyword">volatile</span> <span class="keyword">static</span> voidFuncPtr TimerIntFunc[TIMER_NUM_INTERRUPTS]; |
||
51 | 00044 |
||
52 | 00045 <span class="comment">// delay for a minimum of <us> microseconds </span> |
||
53 | 00046 <span class="comment">// the time resolution is dependent on the time the loop takes </span> |
||
54 | 00047 <span class="comment">// e.g. with 4Mhz and 5 cycles per loop, the resolution is 1.25 us </span> |
||
55 | 00048 <span class="keywordtype">void</span> delay_us(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> time_us) |
||
56 | 00049 { |
||
57 | 00050 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> delay_loops; |
||
58 | 00051 <span class="keyword">register</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> i; |
||
59 | 00052 |
||
60 | 00053 delay_loops = (time_us+3)/5*CYCLES_PER_US; <span class="comment">// +3 for rounding up (dirty) </span> |
||
61 | 00054 |
||
62 | 00055 <span class="comment">// one loop takes 5 cpu cycles </span> |
||
63 | 00056 <span class="keywordflow">for</span> (i=0; i < delay_loops; i++) {}; |
||
64 | 00057 } |
||
65 | 00058 <span class="comment">/*</span> |
||
66 | 00059 <span class="comment">void delay_ms(unsigned char time_ms)</span> |
||
67 | 00060 <span class="comment">{</span> |
||
68 | 00061 <span class="comment"> unsigned short delay_count = F_CPU / 4000;</span> |
||
69 | 00062 <span class="comment"></span> |
||
70 | 00063 <span class="comment"> unsigned short cnt;</span> |
||
71 | 00064 <span class="comment"> asm volatile ("\n"</span> |
||
72 | 00065 <span class="comment"> "L_dl1%=:\n\t"</span> |
||
73 | 00066 <span class="comment"> "mov %A0, %A2\n\t"</span> |
||
74 | 00067 <span class="comment"> "mov %B0, %B2\n"</span> |
||
75 | 00068 <span class="comment"> "L_dl2%=:\n\t"</span> |
||
76 | 00069 <span class="comment"> "sbiw %A0, 1\n\t"</span> |
||
77 | 00070 <span class="comment"> "brne L_dl2%=\n\t"</span> |
||
78 | 00071 <span class="comment"> "dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt)</span> |
||
79 | 00072 <span class="comment"> :"r"(time_ms), "r"((unsigned short) (delay_count))</span> |
||
80 | 00073 <span class="comment"> );</span> |
||
81 | 00074 <span class="comment">}</span> |
||
82 | 00075 <span class="comment">*/</span> |
||
83 | <a name="l00076"></a><a class="code" href="group__timer.html#ga1">00076</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga1">timerInit</a>(<span class="keywordtype">void</span>) |
||
84 | 00077 { |
||
85 | 00078 u08 intNum; |
||
86 | 00079 <span class="comment">// detach all user functions from interrupts</span> |
||
87 | 00080 <span class="keywordflow">for</span>(intNum=0; intNum<TIMER_NUM_INTERRUPTS; intNum++) |
||
88 | 00081 <a class="code" href="group__timer.html#ga9">timerDetach</a>(intNum); |
||
89 | 00082 |
||
90 | 00083 <span class="comment">// initialize all timers</span> |
||
91 | 00084 <a class="code" href="group__timer.html#ga2">timer0Init</a>(); |
||
92 | 00085 <a class="code" href="group__timer.html#ga3">timer1Init</a>(); |
||
93 | 00086 timer2Init(); |
||
94 | 00087 timer3Init(); |
||
95 | 00088 <span class="comment">// enable interrupts</span> |
||
96 | 00089 sei(); |
||
97 | 00090 } |
||
98 | 00091 |
||
99 | <a name="l00092"></a><a class="code" href="group__timer.html#ga2">00092</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga2">timer0Init</a>() |
||
100 | 00093 { |
||
101 | 00094 <span class="comment">// initialize timer 0</span> |
||
102 | 00095 <a class="code" href="group__timer.html#ga4">timer0SetPrescaler</a>( <a class="code" href="group__timer.html#ga33">TIMER0PRESCALE</a> ); <span class="comment">// set prescaler</span> |
||
103 | 00096 outb(TCNT0, 0); <span class="comment">// reset TCNT0</span> |
||
104 | 00097 sbi(TIMSK, TOIE0); <span class="comment">// enable TCNT0 overflow interrupt</span> |
||
105 | 00098 |
||
106 | 00099 <a class="code" href="group__timer.html#ga11">timer0ClearOverflowCount</a>(); <span class="comment">// initialize time registers</span> |
||
107 | 00100 } |
||
108 | 00101 |
||
109 | <a name="l00102"></a><a class="code" href="group__timer.html#ga3">00102</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga3">timer1Init</a>(<span class="keywordtype">void</span>) |
||
110 | 00103 { |
||
111 | 00104 <span class="comment">// initialize timer 1</span> |
||
112 | 00105 <a class="code" href="group__timer.html#ga6">timer1SetPrescaler</a>( <a class="code" href="group__timer.html#ga34">TIMER1PRESCALE</a> ); <span class="comment">// set prescaler</span> |
||
113 | 00106 outb(TCNT1H, 0); <span class="comment">// reset TCNT1</span> |
||
114 | 00107 outb(TCNT1L, 0); |
||
115 | 00108 sbi(TIMSK, TOIE1); <span class="comment">// enable TCNT1 overflow</span> |
||
116 | 00109 } |
||
117 | 00110 |
||
118 | 00111 <span class="keywordtype">void</span> timer2Init(<span class="keywordtype">void</span>) |
||
119 | 00112 { |
||
120 | 00113 <span class="comment">// initialize timer 2</span> |
||
121 | 00114 <a class="code" href="group__timer128.html#ga8">timer2SetPrescaler</a>( <a class="code" href="group__timer.html#ga35">TIMER2PRESCALE</a> ); <span class="comment">// set prescaler</span> |
||
122 | 00115 outb(TCNT2, 0); <span class="comment">// reset TCNT2</span> |
||
123 | 00116 sbi(TIMSK, TOIE2); <span class="comment">// enable TCNT2 overflow</span> |
||
124 | 00117 |
||
125 | 00118 timer2ClearOverflowCount(); <span class="comment">// initialize time registers</span> |
||
126 | 00119 } |
||
127 | 00120 |
||
128 | 00121 <span class="keywordtype">void</span> timer3Init(<span class="keywordtype">void</span>) |
||
129 | 00122 { |
||
130 | 00123 <span class="comment">// initialize timer 3</span> |
||
131 | 00124 <a class="code" href="group__timer128.html#ga9">timer3SetPrescaler</a>( <a class="code" href="group__timer128.html#ga66">TIMER3PRESCALE</a> ); <span class="comment">// set prescaler</span> |
||
132 | 00125 outb(TCNT3H, 0); <span class="comment">// reset TCNT3</span> |
||
133 | 00126 outb(TCNT3L, 0); |
||
134 | 00127 sbi(ETIMSK, TOIE3); <span class="comment">// enable TCNT3 overflow</span> |
||
135 | 00128 } |
||
136 | 00129 |
||
137 | <a name="l00130"></a><a class="code" href="group__timer.html#ga4">00130</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga4">timer0SetPrescaler</a>(u08 prescale) |
||
138 | 00131 { |
||
139 | 00132 <span class="comment">// set prescaler on timer 0</span> |
||
140 | 00133 outb(TCCR0, (inb(TCCR0) & ~<a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>) | prescale); |
||
141 | 00134 } |
||
142 | 00135 |
||
143 | <a name="l00136"></a><a class="code" href="group__timer.html#ga6">00136</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga6">timer1SetPrescaler</a>(u08 prescale) |
||
144 | 00137 { |
||
145 | 00138 <span class="comment">// set prescaler on timer 1</span> |
||
146 | 00139 outb(TCCR1B, (inb(TCCR1B) & ~<a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>) | prescale); |
||
147 | 00140 } |
||
148 | 00141 |
||
149 | <a name="l00142"></a><a class="code" href="group__timer128.html#ga8">00142</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga8">timer2SetPrescaler</a>(u08 prescale) |
||
150 | 00143 { |
||
151 | 00144 <span class="comment">// set prescaler on timer 2</span> |
||
152 | 00145 outb(TCCR2, (inb(TCCR2) & ~<a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>) | prescale); |
||
153 | 00146 } |
||
154 | 00147 |
||
155 | <a name="l00148"></a><a class="code" href="group__timer128.html#ga9">00148</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga9">timer3SetPrescaler</a>(u08 prescale) |
||
156 | 00149 { |
||
157 | 00150 <span class="comment">// set prescaler on timer 2</span> |
||
158 | 00151 outb(TCCR3B, (inb(TCCR3B) & ~<a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>) | prescale); |
||
159 | 00152 } |
||
160 | 00153 |
||
161 | <a name="l00154"></a><a class="code" href="group__timer.html#ga5">00154</a> u16 <a class="code" href="group__timer.html#ga5">timer0GetPrescaler</a>(<span class="keywordtype">void</span>) |
||
162 | 00155 { |
||
163 | 00156 <span class="comment">// get the current prescaler setting</span> |
||
164 | 00157 <span class="keywordflow">return</span> (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & <a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>))); |
||
165 | 00158 } |
||
166 | 00159 |
||
167 | <a name="l00160"></a><a class="code" href="group__timer.html#ga7">00160</a> u16 <a class="code" href="group__timer.html#ga7">timer1GetPrescaler</a>(<span class="keywordtype">void</span>) |
||
168 | 00161 { |
||
169 | 00162 <span class="comment">// get the current prescaler setting</span> |
||
170 | 00163 <span class="keywordflow">return</span> (pgm_read_word(TimerPrescaleFactor+(inb(TCCR1B) & <a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>))); |
||
171 | 00164 } |
||
172 | 00165 |
||
173 | <a name="l00166"></a><a class="code" href="group__timer128.html#ga12">00166</a> u16 <a class="code" href="group__timer128.html#ga12">timer2GetPrescaler</a>(<span class="keywordtype">void</span>) |
||
174 | 00167 { |
||
175 | 00168 <span class="comment">// get the current prescaler setting</span> |
||
176 | 00169 <span class="keywordflow">return</span> (pgm_read_word(TimerPrescaleFactor+(inb(TCCR2) & <a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>))); |
||
177 | 00170 } |
||
178 | 00171 |
||
179 | <a name="l00172"></a><a class="code" href="group__timer128.html#ga13">00172</a> u16 <a class="code" href="group__timer128.html#ga13">timer3GetPrescaler</a>(<span class="keywordtype">void</span>) |
||
180 | 00173 { |
||
181 | 00174 <span class="comment">// get the current prescaler setting</span> |
||
182 | 00175 <span class="keywordflow">return</span> (pgm_read_word(TimerPrescaleFactor+(inb(TCCR3B) & <a class="code" href="group__timer.html#ga23">TIMER_PRESCALE_MASK</a>))); |
||
183 | 00176 } |
||
184 | 00177 |
||
185 | <a name="l00178"></a><a class="code" href="group__timer.html#ga8">00178</a> <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>) ) |
||
186 | 00179 { |
||
187 | 00180 <span class="comment">// make sure the interrupt number is within bounds</span> |
||
188 | 00181 <span class="keywordflow">if</span>(interruptNum < TIMER_NUM_INTERRUPTS) |
||
189 | 00182 { |
||
190 | 00183 <span class="comment">// set the interrupt function to run</span> |
||
191 | 00184 <span class="comment">// the supplied user's function</span> |
||
192 | 00185 TimerIntFunc[interruptNum] = userFunc; |
||
193 | 00186 } |
||
194 | 00187 } |
||
195 | 00188 |
||
196 | <a name="l00189"></a><a class="code" href="group__timer.html#ga9">00189</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga9">timerDetach</a>(u08 interruptNum) |
||
197 | 00190 { |
||
198 | 00191 <span class="comment">// make sure the interrupt number is within bounds</span> |
||
199 | 00192 <span class="keywordflow">if</span>(interruptNum < TIMER_NUM_INTERRUPTS) |
||
200 | 00193 { |
||
201 | 00194 <span class="comment">// set the interrupt function to run nothing</span> |
||
202 | 00195 TimerIntFunc[interruptNum] = 0; |
||
203 | 00196 } |
||
204 | 00197 } |
||
205 | 00198 |
||
206 | <a name="l00199"></a><a class="code" href="group__timer.html#ga10">00199</a> <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) |
||
207 | 00200 { |
||
208 | 00201 <span class="comment">// pauses for exactly <pause_ms> number of milliseconds</span> |
||
209 | 00202 u08 timerThres; |
||
210 | 00203 u32 ticRateHz; |
||
211 | 00204 u32 pause; |
||
212 | 00205 |
||
213 | 00206 <span class="comment">// capture current pause timer value</span> |
||
214 | 00207 timerThres = inb(TCNT2); |
||
215 | 00208 <span class="comment">// reset pause timer overflow count</span> |
||
216 | 00209 TimerPauseReg = 0; |
||
217 | 00210 <span class="comment">// calculate delay for [pause_ms] milliseconds</span> |
||
218 | 00211 <span class="comment">// prescaler division = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR2)))</span> |
||
219 | 00212 ticRateHz = F_CPU/<a class="code" href="group__timer128.html#ga12">timer2GetPrescaler</a>(); |
||
220 | 00213 <span class="comment">// precision management</span> |
||
221 | 00214 <span class="comment">// prevent overflow and precision underflow</span> |
||
222 | 00215 <span class="comment">// -could add more conditions to improve accuracy</span> |
||
223 | 00216 <span class="keywordflow">if</span>( ((ticRateHz < 429497) && (pause_ms <= 10000)) ) |
||
224 | 00217 pause = (pause_ms*ticRateHz)/1000; |
||
225 | 00218 <span class="keywordflow">else</span> |
||
226 | 00219 pause = pause_ms*(ticRateHz/1000); |
||
227 | 00220 |
||
228 | 00221 <span class="comment">// loop until time expires</span> |
||
229 | 00222 <span class="keywordflow">while</span>( ((TimerPauseReg<<8) | inb(TCNT2)) < (pause+timerThres) ) |
||
230 | 00223 { |
||
231 | 00224 <span class="keywordflow">if</span>( TimerPauseReg < (pause>>8)); |
||
232 | 00225 { |
||
233 | 00226 <span class="comment">// save power by idling the processor</span> |
||
234 | 00227 set_sleep_mode(SLEEP_MODE_IDLE); |
||
235 | 00228 sleep_mode(); |
||
236 | 00229 } |
||
237 | 00230 } |
||
238 | 00231 } |
||
239 | 00232 |
||
240 | <a name="l00233"></a><a class="code" href="group__timer.html#ga11">00233</a> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#ga11">timer0ClearOverflowCount</a>(<span class="keywordtype">void</span>) |
||
241 | 00234 { |
||
242 | 00235 <span class="comment">// clear the timer overflow counter registers</span> |
||
243 | 00236 Timer0Reg0 = 0; <span class="comment">// initialize time registers</span> |
||
244 | 00237 Timer0Reg1 = 0; <span class="comment">// initialize time registers</span> |
||
245 | 00238 } |
||
246 | 00239 |
||
247 | <a name="l00240"></a><a class="code" href="group__timer.html#ga12">00240</a> <span class="keywordtype">long</span> <a class="code" href="group__timer.html#ga12">timer0GetOverflowCount</a>(<span class="keywordtype">void</span>) |
||
248 | 00241 { |
||
249 | 00242 <span class="comment">// return the current timer overflow count</span> |
||
250 | 00243 <span class="comment">// (this is since the last timer0ClearOverflowCount() command was called)</span> |
||
251 | 00244 <span class="keywordflow">return</span> Timer0Reg0; |
||
252 | 00245 } |
||
253 | 00246 |
||
254 | 00247 <span class="keywordtype">void</span> timer2ClearOverflowCount(<span class="keywordtype">void</span>) |
||
255 | 00248 { |
||
256 | 00249 <span class="comment">// clear the timer overflow counter registers</span> |
||
257 | 00250 Timer2Reg0 = 0; <span class="comment">// initialize time registers</span> |
||
258 | 00251 Timer2Reg1 = 0; <span class="comment">// initialize time registers</span> |
||
259 | 00252 } |
||
260 | 00253 |
||
261 | 00254 <span class="keywordtype">long</span> timer2GetOverflowCount(<span class="keywordtype">void</span>) |
||
262 | 00255 { |
||
263 | 00256 <span class="comment">// return the current timer overflow count</span> |
||
264 | 00257 <span class="comment">// (this is since the last timer2ClearOverflowCount() command was called)</span> |
||
265 | 00258 <span class="keywordflow">return</span> Timer2Reg0; |
||
266 | 00259 } |
||
267 | 00260 |
||
268 | 00261 |
||
269 | <a name="l00262"></a><a class="code" href="group__timerpwm.html#ga0">00262</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga0">timer1PWMInit</a>(u08 bitRes) |
||
270 | 00263 { |
||
271 | 00264 <span class="comment">// configures timer1 for use with PWM output</span> |
||
272 | 00265 <span class="comment">// on pins OC1A, OC1B, and OC1C</span> |
||
273 | 00266 |
||
274 | 00267 <span class="comment">// enable Timer1 as 8,9,10bit PWM</span> |
||
275 | 00268 <span class="keywordflow">if</span>(bitRes == 9) |
||
276 | 00269 { <span class="comment">// 9bit mode</span> |
||
277 | 00270 sbi(TCCR1A,WGMA1); |
||
278 | 00271 cbi(TCCR1A,WGMA0); |
||
279 | 00272 } |
||
280 | 00273 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( bitRes == 10 ) |
||
281 | 00274 { <span class="comment">// 10bit mode</span> |
||
282 | 00275 sbi(TCCR1A,WGMA1); |
||
283 | 00276 sbi(TCCR1A,WGMA0); |
||
284 | 00277 } |
||
285 | 00278 <span class="keywordflow">else</span> |
||
286 | 00279 { <span class="comment">// default 8bit mode</span> |
||
287 | 00280 cbi(TCCR1A,WGMA1); |
||
288 | 00281 sbi(TCCR1A,WGMA0); |
||
289 | 00282 } |
||
290 | 00283 |
||
291 | 00284 <span class="comment">// set clear-timer-on-compare-match</span> |
||
292 | 00285 <span class="comment">//cbi(TCCR1B,CTC1);</span> |
||
293 | 00286 <span class="comment">// clear output compare value A</span> |
||
294 | 00287 outb(OCR1AH, 0); |
||
295 | 00288 outb(OCR1AL, 0); |
||
296 | 00289 <span class="comment">// clear output compare value B</span> |
||
297 | 00290 outb(OCR1BH, 0); |
||
298 | 00291 outb(OCR1BL, 0); |
||
299 | 00292 <span class="comment">// clear output compare value C</span> |
||
300 | 00293 outb(OCR1CH, 0); |
||
301 | 00294 outb(OCR1CL, 0); |
||
302 | 00295 } |
||
303 | 00296 |
||
304 | <a name="l00297"></a><a class="code" href="group__timer128.html#ga22">00297</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga1">timer1PWMInitICR</a>(u16 topcount) |
||
305 | 00298 { |
||
306 | 00299 <span class="comment">// set PWM mode with ICR top-count</span> |
||
307 | 00300 cbi(TCCR1A,WGM10); |
||
308 | 00301 sbi(TCCR1A,WGM11); |
||
309 | 00302 sbi(TCCR1B,WGM12); |
||
310 | 00303 sbi(TCCR1B,WGM13); |
||
311 | 00304 |
||
312 | 00305 <span class="comment">// set top count value</span> |
||
313 | 00306 ICR1H = (u08)(topcount>>8); |
||
314 | 00307 ICR1L = (u08)topcount; |
||
315 | 00308 |
||
316 | 00309 <span class="comment">// clear output compare value A</span> |
||
317 | 00310 outb(OCR1AH, 0); |
||
318 | 00311 outb(OCR1AL, 0); |
||
319 | 00312 <span class="comment">// clear output compare value B</span> |
||
320 | 00313 outb(OCR1BH, 0); |
||
321 | 00314 outb(OCR1BL, 0); |
||
322 | 00315 <span class="comment">// clear output compare value C</span> |
||
323 | 00316 outb(OCR1CH, 0); |
||
324 | 00317 outb(OCR1CL, 0); |
||
325 | 00318 } |
||
326 | 00319 |
||
327 | <a name="l00320"></a><a class="code" href="group__timerpwm.html#ga2">00320</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga2">timer1PWMOff</a>(<span class="keywordtype">void</span>) |
||
328 | 00321 { |
||
329 | 00322 <span class="comment">// turn off PWM on Timer1</span> |
||
330 | 00323 cbi(TCCR1A,WGMA1); |
||
331 | 00324 cbi(TCCR1A,WGMA0); |
||
332 | 00325 <span class="comment">// clear (disable) clear-timer-on-compare-match</span> |
||
333 | 00326 <span class="comment">//cbi(TCCR1B,CTC1);</span> |
||
334 | 00327 <span class="comment">// set PWM1A/B/C (OutputCompare action) to none</span> |
||
335 | 00328 <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>(); |
||
336 | 00329 <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>(); |
||
337 | 00330 <a class="code" href="group__timer128.html#ga29">timer1PWMCOff</a>(); |
||
338 | 00331 } |
||
339 | 00332 |
||
340 | <a name="l00333"></a><a class="code" href="group__timerpwm.html#ga3">00333</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga3">timer1PWMAOn</a>(<span class="keywordtype">void</span>) |
||
341 | 00334 { |
||
342 | 00335 <span class="comment">// turn on channel A (OC1A) PWM output</span> |
||
343 | 00336 <span class="comment">// set OC1A as non-inverted PWM</span> |
||
344 | 00337 sbi(TCCR1A,COMA1); |
||
345 | 00338 cbi(TCCR1A,COMA0); |
||
346 | 00339 } |
||
347 | 00340 |
||
348 | <a name="l00341"></a><a class="code" href="group__timerpwm.html#ga4">00341</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga4">timer1PWMBOn</a>(<span class="keywordtype">void</span>) |
||
349 | 00342 { |
||
350 | 00343 <span class="comment">// turn on channel B (OC1B) PWM output</span> |
||
351 | 00344 <span class="comment">// set OC1B as non-inverted PWM</span> |
||
352 | 00345 sbi(TCCR1A,COMB1); |
||
353 | 00346 cbi(TCCR1A,COMB0); |
||
354 | 00347 } |
||
355 | 00348 |
||
356 | <a name="l00349"></a><a class="code" href="group__timer128.html#ga26">00349</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga26">timer1PWMCOn</a>(<span class="keywordtype">void</span>) |
||
357 | 00350 { |
||
358 | 00351 <span class="comment">// turn on channel C (OC1C) PWM output</span> |
||
359 | 00352 <span class="comment">// set OC1C as non-inverted PWM</span> |
||
360 | 00353 sbi(TCCR1A,COMC1); |
||
361 | 00354 cbi(TCCR1A,COMC0); |
||
362 | 00355 } |
||
363 | 00356 |
||
364 | <a name="l00357"></a><a class="code" href="group__timerpwm.html#ga5">00357</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>(<span class="keywordtype">void</span>) |
||
365 | 00358 { |
||
366 | 00359 <span class="comment">// turn off channel A (OC1A) PWM output</span> |
||
367 | 00360 <span class="comment">// set OC1A (OutputCompare action) to none</span> |
||
368 | 00361 cbi(TCCR1A,COMA1); |
||
369 | 00362 cbi(TCCR1A,COMA0); |
||
370 | 00363 } |
||
371 | 00364 |
||
372 | <a name="l00365"></a><a class="code" href="group__timerpwm.html#ga6">00365</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>(<span class="keywordtype">void</span>) |
||
373 | 00366 { |
||
374 | 00367 <span class="comment">// turn off channel B (OC1B) PWM output</span> |
||
375 | 00368 <span class="comment">// set OC1B (OutputCompare action) to none</span> |
||
376 | 00369 cbi(TCCR1A,COMB1); |
||
377 | 00370 cbi(TCCR1A,COMB0); |
||
378 | 00371 } |
||
379 | 00372 |
||
380 | <a name="l00373"></a><a class="code" href="group__timer128.html#ga29">00373</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga29">timer1PWMCOff</a>(<span class="keywordtype">void</span>) |
||
381 | 00374 { |
||
382 | 00375 <span class="comment">// turn off channel C (OC1C) PWM output</span> |
||
383 | 00376 <span class="comment">// set OC1C (OutputCompare action) to none</span> |
||
384 | 00377 cbi(TCCR1A,COMC1); |
||
385 | 00378 cbi(TCCR1A,COMC0); |
||
386 | 00379 } |
||
387 | 00380 |
||
388 | <a name="l00381"></a><a class="code" href="group__timerpwm.html#ga7">00381</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga7">timer1PWMASet</a>(u16 pwmDuty) |
||
389 | 00382 { |
||
390 | 00383 <span class="comment">// set PWM (output compare) duty for channel A</span> |
||
391 | 00384 <span class="comment">// this PWM output is generated on OC1A pin</span> |
||
392 | 00385 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span> |
||
393 | 00386 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span> |
||
394 | 00387 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span> |
||
395 | 00388 outb(OCR1AH, (pwmDuty>>8)); <span class="comment">// set the high 8bits of OCR1A</span> |
||
396 | 00389 outb(OCR1AL, (pwmDuty&0x00FF)); <span class="comment">// set the low 8bits of OCR1A</span> |
||
397 | 00390 } |
||
398 | 00391 |
||
399 | <a name="l00392"></a><a class="code" href="group__timerpwm.html#ga8">00392</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga8">timer1PWMBSet</a>(u16 pwmDuty) |
||
400 | 00393 { |
||
401 | 00394 <span class="comment">// set PWM (output compare) duty for channel B</span> |
||
402 | 00395 <span class="comment">// this PWM output is generated on OC1B pin</span> |
||
403 | 00396 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span> |
||
404 | 00397 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span> |
||
405 | 00398 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span> |
||
406 | 00399 outb(OCR1BH, (pwmDuty>>8)); <span class="comment">// set the high 8bits of OCR1B</span> |
||
407 | 00400 outb(OCR1BL, (pwmDuty&0x00FF)); <span class="comment">// set the low 8bits of OCR1B</span> |
||
408 | 00401 } |
||
409 | 00402 |
||
410 | <a name="l00403"></a><a class="code" href="group__timer128.html#ga32">00403</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga32">timer1PWMCSet</a>(u16 pwmDuty) |
||
411 | 00404 { |
||
412 | 00405 <span class="comment">// set PWM (output compare) duty for channel C</span> |
||
413 | 00406 <span class="comment">// this PWM output is generated on OC1C pin</span> |
||
414 | 00407 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span> |
||
415 | 00408 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span> |
||
416 | 00409 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span> |
||
417 | 00410 outb(OCR1CH, (pwmDuty>>8)); <span class="comment">// set the high 8bits of OCR1C</span> |
||
418 | 00411 outb(OCR1CL, (pwmDuty&0x00FF)); <span class="comment">// set the low 8bits of OCR1C</span> |
||
419 | 00412 } |
||
420 | 00413 |
||
421 | 00414 |
||
422 | <a name="l00415"></a><a class="code" href="group__timer128.html#ga33">00415</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga33">timer3PWMInit</a>(u08 bitRes) |
||
423 | 00416 { |
||
424 | 00417 <span class="comment">// configures timer1 for use with PWM output</span> |
||
425 | 00418 <span class="comment">// on pins OC3A, OC3B, and OC3C</span> |
||
426 | 00419 |
||
427 | 00420 <span class="comment">// enable Timer3 as 8,9,10bit PWM</span> |
||
428 | 00421 <span class="keywordflow">if</span>(bitRes == 9) |
||
429 | 00422 { <span class="comment">// 9bit mode</span> |
||
430 | 00423 sbi(TCCR3A,WGMA1); |
||
431 | 00424 cbi(TCCR3A,WGMA0); |
||
432 | 00425 } |
||
433 | 00426 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( bitRes == 10 ) |
||
434 | 00427 { <span class="comment">// 10bit mode</span> |
||
435 | 00428 sbi(TCCR3A,WGMA1); |
||
436 | 00429 sbi(TCCR3A,WGMA0); |
||
437 | 00430 } |
||
438 | 00431 <span class="keywordflow">else</span> |
||
439 | 00432 { <span class="comment">// default 8bit mode</span> |
||
440 | 00433 cbi(TCCR3A,WGMA1); |
||
441 | 00434 sbi(TCCR3A,WGMA0); |
||
442 | 00435 } |
||
443 | 00436 |
||
444 | 00437 <span class="comment">// set clear-timer-on-compare-match</span> |
||
445 | 00438 <span class="comment">//cbi(TCCR3B,CTC1);</span> |
||
446 | 00439 <span class="comment">// clear output compare value A</span> |
||
447 | 00440 outb(OCR3AH, 0); |
||
448 | 00441 outb(OCR3AL, 0); |
||
449 | 00442 <span class="comment">// clear output compare value B</span> |
||
450 | 00443 outb(OCR3BH, 0); |
||
451 | 00444 outb(OCR3BL, 0); |
||
452 | 00445 <span class="comment">// clear output compare value B</span> |
||
453 | 00446 outb(OCR3CH, 0); |
||
454 | 00447 outb(OCR3CL, 0); |
||
455 | 00448 } |
||
456 | 00449 |
||
457 | <a name="l00450"></a><a class="code" href="group__timer128.html#ga34">00450</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga34">timer3PWMInitICR</a>(u16 topcount) |
||
458 | 00451 { |
||
459 | 00452 <span class="comment">// set PWM mode with ICR top-count</span> |
||
460 | 00453 cbi(TCCR3A,WGM30); |
||
461 | 00454 sbi(TCCR3A,WGM31); |
||
462 | 00455 sbi(TCCR3B,WGM32); |
||
463 | 00456 sbi(TCCR3B,WGM33); |
||
464 | 00457 |
||
465 | 00458 <span class="comment">// set top count value</span> |
||
466 | 00459 ICR3H = (u08)(topcount>>8); |
||
467 | 00460 ICR3L = (u08)topcount; |
||
468 | 00461 |
||
469 | 00462 <span class="comment">// clear output compare value A</span> |
||
470 | 00463 outb(OCR3AH, 0); |
||
471 | 00464 outb(OCR3AL, 0); |
||
472 | 00465 <span class="comment">// clear output compare value B</span> |
||
473 | 00466 outb(OCR3BH, 0); |
||
474 | 00467 outb(OCR3BL, 0); |
||
475 | 00468 <span class="comment">// clear output compare value C</span> |
||
476 | 00469 outb(OCR3CH, 0); |
||
477 | 00470 outb(OCR3CL, 0); |
||
478 | 00471 } |
||
479 | 00472 |
||
480 | <a name="l00473"></a><a class="code" href="group__timer128.html#ga35">00473</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga35">timer3PWMOff</a>(<span class="keywordtype">void</span>) |
||
481 | 00474 { |
||
482 | 00475 <span class="comment">// turn off PWM mode on Timer3</span> |
||
483 | 00476 cbi(TCCR3A,WGMA1); |
||
484 | 00477 cbi(TCCR3A,WGMA0); |
||
485 | 00478 <span class="comment">// clear (disable) clear-timer-on-compare-match</span> |
||
486 | 00479 <span class="comment">//cbi(TCCR3B,CTC1);</span> |
||
487 | 00480 <span class="comment">// set OC3A/B/C (OutputCompare action) to none</span> |
||
488 | 00481 <a class="code" href="group__timer128.html#ga39">timer3PWMAOff</a>(); |
||
489 | 00482 <a class="code" href="group__timer128.html#ga40">timer3PWMBOff</a>(); |
||
490 | 00483 <a class="code" href="group__timer128.html#ga41">timer3PWMCOff</a>(); |
||
491 | 00484 } |
||
492 | 00485 |
||
493 | <a name="l00486"></a><a class="code" href="group__timer128.html#ga36">00486</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga36">timer3PWMAOn</a>(<span class="keywordtype">void</span>) |
||
494 | 00487 { |
||
495 | 00488 <span class="comment">// turn on channel A (OC3A) PWM output</span> |
||
496 | 00489 <span class="comment">// set OC3A as non-inverted PWM</span> |
||
497 | 00490 sbi(TCCR3A,COMA1); |
||
498 | 00491 cbi(TCCR3A,COMA0); |
||
499 | 00492 } |
||
500 | 00493 |
||
501 | <a name="l00494"></a><a class="code" href="group__timer128.html#ga37">00494</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga37">timer3PWMBOn</a>(<span class="keywordtype">void</span>) |
||
502 | 00495 { |
||
503 | 00496 <span class="comment">// turn on channel B (OC3B) PWM output</span> |
||
504 | 00497 <span class="comment">// set OC3B as non-inverted PWM</span> |
||
505 | 00498 sbi(TCCR3A,COMB1); |
||
506 | 00499 cbi(TCCR3A,COMB0); |
||
507 | 00500 } |
||
508 | 00501 |
||
509 | <a name="l00502"></a><a class="code" href="group__timer128.html#ga38">00502</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga38">timer3PWMCOn</a>(<span class="keywordtype">void</span>) |
||
510 | 00503 { |
||
511 | 00504 <span class="comment">// turn on channel C (OC3C) PWM output</span> |
||
512 | 00505 <span class="comment">// set OC3C as non-inverted PWM</span> |
||
513 | 00506 sbi(TCCR3A,COMC1); |
||
514 | 00507 cbi(TCCR3A,COMC0); |
||
515 | 00508 } |
||
516 | 00509 |
||
517 | <a name="l00510"></a><a class="code" href="group__timer128.html#ga39">00510</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga39">timer3PWMAOff</a>(<span class="keywordtype">void</span>) |
||
518 | 00511 { |
||
519 | 00512 <span class="comment">// turn off channel A (OC3A) PWM output</span> |
||
520 | 00513 <span class="comment">// set OC3A (OutputCompare action) to none</span> |
||
521 | 00514 cbi(TCCR3A,COMA1); |
||
522 | 00515 cbi(TCCR3A,COMA0); |
||
523 | 00516 } |
||
524 | 00517 |
||
525 | <a name="l00518"></a><a class="code" href="group__timer128.html#ga40">00518</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga40">timer3PWMBOff</a>(<span class="keywordtype">void</span>) |
||
526 | 00519 { |
||
527 | 00520 <span class="comment">// turn off channel B (OC3B) PWM output</span> |
||
528 | 00521 <span class="comment">// set OC3B (OutputCompare action) to none</span> |
||
529 | 00522 cbi(TCCR3A,COMB1); |
||
530 | 00523 cbi(TCCR3A,COMB0); |
||
531 | 00524 } |
||
532 | 00525 |
||
533 | <a name="l00526"></a><a class="code" href="group__timer128.html#ga41">00526</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga41">timer3PWMCOff</a>(<span class="keywordtype">void</span>) |
||
534 | 00527 { |
||
535 | 00528 <span class="comment">// turn off channel C (OC3C) PWM output</span> |
||
536 | 00529 <span class="comment">// set OC3C (OutputCompare action) to none</span> |
||
537 | 00530 cbi(TCCR3A,COMC1); |
||
538 | 00531 cbi(TCCR3A,COMC0); |
||
539 | 00532 } |
||
540 | 00533 |
||
541 | <a name="l00534"></a><a class="code" href="group__timer128.html#ga42">00534</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga42">timer3PWMASet</a>(u16 pwmDuty) |
||
542 | 00535 { |
||
543 | 00536 <span class="comment">// set PWM (output compare) duty for channel A</span> |
||
544 | 00537 <span class="comment">// this PWM output is generated on OC3A pin</span> |
||
545 | 00538 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span> |
||
546 | 00539 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span> |
||
547 | 00540 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span> |
||
548 | 00541 outb(OCR3AH, (pwmDuty>>8)); <span class="comment">// set the high 8bits of OCR3A</span> |
||
549 | 00542 outb(OCR3AL, (pwmDuty&0x00FF)); <span class="comment">// set the low 8bits of OCR3A</span> |
||
550 | 00543 } |
||
551 | 00544 |
||
552 | <a name="l00545"></a><a class="code" href="group__timer128.html#ga43">00545</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga43">timer3PWMBSet</a>(u16 pwmDuty) |
||
553 | 00546 { |
||
554 | 00547 <span class="comment">// set PWM (output compare) duty for channel B</span> |
||
555 | 00548 <span class="comment">// this PWM output is generated on OC3B pin</span> |
||
556 | 00549 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span> |
||
557 | 00550 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span> |
||
558 | 00551 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span> |
||
559 | 00552 outb(OCR3BH, (pwmDuty>>8)); <span class="comment">// set the high 8bits of OCR3B</span> |
||
560 | 00553 outb(OCR3BL, (pwmDuty&0x00FF)); <span class="comment">// set the low 8bits of OCR3B</span> |
||
561 | 00554 } |
||
562 | 00555 |
||
563 | <a name="l00556"></a><a class="code" href="group__timer128.html#ga44">00556</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga44">timer3PWMCSet</a>(u16 pwmDuty) |
||
564 | 00557 { |
||
565 | 00558 <span class="comment">// set PWM (output compare) duty for channel B</span> |
||
566 | 00559 <span class="comment">// this PWM output is generated on OC3C pin</span> |
||
567 | 00560 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span> |
||
568 | 00561 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span> |
||
569 | 00562 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span> |
||
570 | 00563 outb(OCR3CH, (pwmDuty>>8)); <span class="comment">// set the high 8bits of OCR3C</span> |
||
571 | 00564 outb(OCR3CL, (pwmDuty&0x00FF)); <span class="comment">// set the low 8bits of OCR3C</span> |
||
572 | 00565 } |
||
573 | 00566 |
||
574 | 00567 <span class="comment"></span> |
||
575 | 00568 <span class="comment">//! Interrupt handler for tcnt0 overflow interrupt</span> |
||
576 | <a name="l00569"></a><a class="code" href="timer128_8c.html#a53">00569</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0) |
||
577 | 00570 { |
||
578 | 00571 Timer0Reg0++; <span class="comment">// increment low-order counter</span> |
||
579 | 00572 <span class="keywordflow">if</span>(!Timer0Reg0) <span class="comment">// if low-order counter rollover</span> |
||
580 | 00573 Timer0Reg1++; <span class="comment">// increment high-order counter </span> |
||
581 | 00574 |
||
582 | 00575 <span class="comment">// if a user function is defined, execute it too</span> |
||
583 | 00576 <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OVERFLOW_INT]) |
||
584 | 00577 TimerIntFunc[TIMER0OVERFLOW_INT](); |
||
585 | 00578 } |
||
586 | 00579 <span class="comment"></span> |
||
587 | 00580 <span class="comment">//! Interrupt handler for Timer1 overflow interrupt</span> |
||
588 | <a name="l00581"></a><a class="code" href="timer128_8c.html#a54">00581</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1) |
||
589 | 00582 { |
||
590 | 00583 <span class="comment">// if a user function is defined, execute it</span> |
||
591 | 00584 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OVERFLOW_INT]) |
||
592 | 00585 TimerIntFunc[TIMER1OVERFLOW_INT](); |
||
593 | 00586 } |
||
594 | 00587 <span class="comment"></span> |
||
595 | 00588 <span class="comment">//! Interrupt handler for Timer2 overflow interrupt</span> |
||
596 | <a name="l00589"></a><a class="code" href="timer128_8c.html#a55">00589</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2) |
||
597 | 00590 { |
||
598 | 00591 Timer2Reg0++; <span class="comment">// increment low-order counter</span> |
||
599 | 00592 <span class="keywordflow">if</span>(!Timer2Reg0) <span class="comment">// if low-order counter rollover</span> |
||
600 | 00593 Timer2Reg1++; <span class="comment">// increment high-order counter </span> |
||
601 | 00594 |
||
602 | 00595 <span class="comment">// increment pause counter</span> |
||
603 | 00596 TimerPauseReg++; |
||
604 | 00597 |
||
605 | 00598 <span class="comment">// if a user function is defined, execute it</span> |
||
606 | 00599 <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OVERFLOW_INT]) |
||
607 | 00600 TimerIntFunc[TIMER2OVERFLOW_INT](); |
||
608 | 00601 } |
||
609 | 00602 <span class="comment"></span> |
||
610 | 00603 <span class="comment">//! Interrupt handler for Timer3 overflow interrupt</span> |
||
611 | <a name="l00604"></a><a class="code" href="timer128_8c.html#a56">00604</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW3) |
||
612 | 00605 { |
||
613 | 00606 <span class="comment">// if a user function is defined, execute it</span> |
||
614 | 00607 <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OVERFLOW_INT]) |
||
615 | 00608 TimerIntFunc[TIMER3OVERFLOW_INT](); |
||
616 | 00609 } |
||
617 | 00610 <span class="comment"></span> |
||
618 | 00611 <span class="comment">//! Interrupt handler for OutputCompare0 match (OC0) interrupt</span> |
||
619 | <a name="l00612"></a><a class="code" href="timer128_8c.html#a57">00612</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0) |
||
620 | 00613 { |
||
621 | 00614 <span class="comment">// if a user function is defined, execute it</span> |
||
622 | 00615 <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OUTCOMPARE_INT]) |
||
623 | 00616 TimerIntFunc[TIMER0OUTCOMPARE_INT](); |
||
624 | 00617 } |
||
625 | 00618 <span class="comment"></span> |
||
626 | 00619 <span class="comment">//! Interrupt handler for OutputCompare1A match (OC1A) interrupt</span> |
||
627 | <a name="l00620"></a><a class="code" href="timer128_8c.html#a58">00620</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1A) |
||
628 | 00621 { |
||
629 | 00622 <span class="comment">// if a user function is defined, execute it</span> |
||
630 | 00623 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREA_INT]) |
||
631 | 00624 TimerIntFunc[TIMER1OUTCOMPAREA_INT](); |
||
632 | 00625 } |
||
633 | 00626 <span class="comment"></span> |
||
634 | 00627 <span class="comment">//! Interrupt handler for OutputCompare1B match (OC1B) interrupt</span> |
||
635 | <a name="l00628"></a><a class="code" href="timer128_8c.html#a59">00628</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1B) |
||
636 | 00629 { |
||
637 | 00630 <span class="comment">// if a user function is defined, execute it</span> |
||
638 | 00631 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREB_INT]) |
||
639 | 00632 TimerIntFunc[TIMER1OUTCOMPAREB_INT](); |
||
640 | 00633 } |
||
641 | 00634 <span class="comment"></span> |
||
642 | 00635 <span class="comment">//! Interrupt handler for OutputCompare1C match (OC1C) interrupt</span> |
||
643 | <a name="l00636"></a><a class="code" href="timer128_8c.html#a60">00636</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1C) |
||
644 | 00637 { |
||
645 | 00638 <span class="comment">// if a user function is defined, execute it</span> |
||
646 | 00639 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREC_INT]) |
||
647 | 00640 TimerIntFunc[TIMER1OUTCOMPAREC_INT](); |
||
648 | 00641 } |
||
649 | 00642 <span class="comment"></span> |
||
650 | 00643 <span class="comment">//! Interrupt handler for InputCapture1(IC1) interrupt</span> |
||
651 | <a name="l00644"></a><a class="code" href="timer128_8c.html#a61">00644</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE1) |
||
652 | 00645 { |
||
653 | 00646 <span class="comment">// if a user function is defined, execute it</span> |
||
654 | 00647 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1INPUTCAPTURE_INT]) |
||
655 | 00648 TimerIntFunc[TIMER1INPUTCAPTURE_INT](); |
||
656 | 00649 } |
||
657 | 00650 <span class="comment"></span> |
||
658 | 00651 <span class="comment">//! Interrupt handler for OutputCompare2 match (OC2) interrupt</span> |
||
659 | <a name="l00652"></a><a class="code" href="timer128_8c.html#a62">00652</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2) |
||
660 | 00653 { |
||
661 | 00654 <span class="comment">// if a user function is defined, execute it</span> |
||
662 | 00655 <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OUTCOMPARE_INT]) |
||
663 | 00656 TimerIntFunc[TIMER2OUTCOMPARE_INT](); |
||
664 | 00657 } |
||
665 | 00658 <span class="comment"></span> |
||
666 | 00659 <span class="comment">//! Interrupt handler for OutputCompare3A match (OC3A) interrupt</span> |
||
667 | <a name="l00660"></a><a class="code" href="timer128_8c.html#a63">00660</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3A) |
||
668 | 00661 { |
||
669 | 00662 <span class="comment">// if a user function is defined, execute it</span> |
||
670 | 00663 <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREA_INT]) |
||
671 | 00664 TimerIntFunc[TIMER3OUTCOMPAREA_INT](); |
||
672 | 00665 } |
||
673 | 00666 <span class="comment"></span> |
||
674 | 00667 <span class="comment">//! Interrupt handler for OutputCompare3B match (OC3B) interrupt</span> |
||
675 | <a name="l00668"></a><a class="code" href="timer128_8c.html#a64">00668</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3B) |
||
676 | 00669 { |
||
677 | 00670 <span class="comment">// if a user function is defined, execute it</span> |
||
678 | 00671 <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREB_INT]) |
||
679 | 00672 TimerIntFunc[TIMER3OUTCOMPAREB_INT](); |
||
680 | 00673 } |
||
681 | 00674 <span class="comment"></span> |
||
682 | 00675 <span class="comment">//! Interrupt handler for OutputCompare3C match (OC3C) interrupt</span> |
||
683 | <a name="l00676"></a><a class="code" href="timer128_8c.html#a65">00676</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3C) |
||
684 | 00677 { |
||
685 | 00678 <span class="comment">// if a user function is defined, execute it</span> |
||
686 | 00679 <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREC_INT]) |
||
687 | 00680 TimerIntFunc[TIMER3OUTCOMPAREC_INT](); |
||
688 | 00681 } |
||
689 | 00682 <span class="comment"></span> |
||
690 | 00683 <span class="comment">//! Interrupt handler for InputCapture3 (IC3) interrupt</span> |
||
691 | <a name="l00684"></a><a class="code" href="timer128_8c.html#a66">00684</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE3) |
||
692 | 00685 { |
||
693 | 00686 <span class="comment">// if a user function is defined, execute it</span> |
||
694 | 00687 <span class="keywordflow">if</span>(TimerIntFunc[TIMER3INPUTCAPTURE_INT]) |
||
695 | 00688 TimerIntFunc[TIMER3INPUTCAPTURE_INT](); |
||
696 | 00689 } |
||
697 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by |
||
698 | <a href="http://www.doxygen.org/index.html"> |
||
699 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
700 | </body> |
||
701 | </html> |
Powered by WebSVN v2.8.3