Częstotliwości wywołania funkcji obsługi przerwania SIG_OUTPUT_COMPARE2

    -- Sebastian Pawlak, 2004.


Tabela pozwala na wyznaczenie częstotliwości z jaką będzie wywoływana funkcja obsługi przerwania SIG_OUT_COMPARE2. Częstotliwość zależy od kilku parametrów: częstotliwości kwarcu, prescalera, OCR2.

Częstotliwość wyznacza się ze wzoru:
freq. = kwarc / (prescaler * (OCR2 + 1))


Kod źródłowy pliku "init.c":

ASSR = 1 << AS2;
TCCR2 = (1 << WGM21) |
        (1 << CS22) | (1 << CS21) | (1 << CS20);  /* prescaler 1024 */
TIFR = 1 << OCF2;
TIMSK = 1 << OCIE2;
OCR2 = 7;  /* 7 = 4 Hz, przy prescalerze 1024 i kwarcu 32768 Hz */

while (ASSR & (1 << OCR2UB))
    ;

sei();

Dla jakiej częstotliwości kwarcu wygenerować tabelę:

32700 Hz
32768 Hz
1 MHz
1834320 Hz
2 MHz
3686400 Hz
4 MHz
6 MHz
7372800 Hz
8 MHz
8867238 Hz
11059200 Hz
14745600 Hz
16 MHz
18432000 Hz
20 MHz


Kwarc: 3686400 Hz
OCR2  Prescaler Freq. Prescaler Freq. Prescaler Freq. Prescaler Freq. Prescaler Freq. Prescaler Freq. 
01024360025614400645760032115200846080013686400
110241800256720064288003257600823040011843200
210241200256480064192003238400815360011228800
3102490025636006414400322880081152001921600
410247202562880641152032230408921601737280
51024600256240064960032192008768001614400
61024514.2862562057.143648228.5713216457.143865828.5711526628.571
71024450256180064720032144008576001460800
81024400256160064640032128008512001409600
91024360256144064576032115208460801368640
101024327.2732561309.091645236.3643210472.727841890.9091335127.273
11102430025612006448003296008384001307200
121024276.9232561107.692644430.769328861.538835446.1541283569.231
131024257.1432561028.571644114.286328228.571832914.2861263314.286
1410242402569606438403276808307201245760
1510242252569006436003272008288001230400
161024211.765256847.059643388.235326776.471827105.8821216847.059
1710242002568006432003264008256001204800
181024189.474256757.895643031.579326063.158824252.6321194021.053
1910241802567206428803257608230401184320
201024171.429256685.714642742.857325485.714821942.8571175542.857
211024163.636256654.545642618.182325236.364820945.4551167563.636
221024156.522256626.087642504.348325008.696820034.7831160278.261
2310241502566006424003248008192001153600
2410241442565766423043246088184321147456
251024138.462256553.846642215.385324430.769817723.0771141784.615
261024133.333256533.333642133.333324266.667817066.6671136533.333
271024128.571256514.286642057.143324114.286816457.1431131657.143
281024124.138256496.552641986.207323972.414815889.6551127117.241
2910241202564806419203238408153601122880
301024116.129256464.516641858.065323716.129814864.5161118916.129
311024112.5002564506418003236008144001115200
321024109.091256436.364641745.455323490.909813963.6361111709.091
331024105.882256423.529641694.118323388.235813552.9411108423.529
341024102.857256411.429641645.714323291.429813165.7141105325.714
3510241002564006416003232008128001102400
36102497.297256389.189641556.757323113.514812454.054199632.432
37102494.737256378.947641515.789323031.579812126.316197010.526
38102492.308256369.231641476.923322953.846811815.385194523.077
39102490256360641440322880811520192160
40102487.805256351.220641404.878322809.756811239.024189912.195
41102485.714256342.857641371.429322742.857810971.429187771.429
42102483.721256334.884641339.535322679.070810716.279185730.233
43102481.818256327.273641309.091322618.182810472.727183781.818
44102480256320641280322560810240181920
45102478.261256313.043641252.174322504.348810017.391180139.130
46102476.596256306.383641225.532322451.06489804.255178434.043
4710247525630064120032240089600176800
48102473.469256293.878641175.510322351.02089404.082175232.653
4910247225628864115232230489216173728
50102470.588256282.353641129.412322258.82489035.294172282.353
51102469.231256276.923641107.692322215.38588861.538170892.308
52102467.925256271.698641086.792322173.58588694.340169554.717
53102466.667256266.667641066.667322133.33388533.333168266.667
54102465.455256261.818641047.273322094.54588378.182167025.455
55102464.286256257.143641028.571322057.14388228.571165828.571
56102463.158256252.632641010.526322021.05388084.211164673.684
57102462.069256248.27664993.103321986.20787944.828163558.621
58102461.017256244.06864976.271321952.54287810.169162481.356
591024602562406496032192087680161440
60102459.016256236.06664944.262321888.52587554.098160432.787
61102458.065256232.25864929.032321858.06587432.258159458.065
62102457.143256228.57164914.286321828.57187314.286158514.286
63102456.2502562256490032180087200157600
64102455.385256221.53864886.154321772.30887089.231156713.846
65102454.545256218.18264872.727321745.45586981.818155854.545
66102453.731256214.92564859.701321719.40386877.612155020.896
67102452.941256211.76564847.059321694.11886776.471154211.765
68102452.174256208.69664834.783321669.56586678.261153426.087
69102451.429256205.71464822.857321645.71486582.857152662.857
70102450.704256202.81764811.268321622.53586490.141151921.127
711024502562006480032160086400151200
72102449.315256197.26064789.041321578.08286312.329150498.630
73102448.649256194.59564778.378321556.75786227.027149816.216
741024482561926476832153686144149152
75102447.368256189.47464757.895321515.78986063.158148505.263
76102446.753256187.01364748.052321496.10485984.416147875.325
77102446.154256184.61564738.462321476.92385907.692147261.538
78102445.570256182.27864729.114321458.22885832.911146663.291
791024452561806472032144085760146080
80102444.444256177.77864711.111321422.22285688.889145511.111
81102443.902256175.61064702.439321404.87885619.512144956.098
82102443.373256173.49464693.976321387.95285551.807144414.458
83102442.857256171.42964685.714321371.42985485.714143885.714
84102442.353256169.41264677.647321355.29485421.176143369.412
85102441.860256167.44264669.767321339.53585358.140142865.116
86102441.379256165.51764662.069321324.13885296.552142372.414
87102440.909256163.63664654.545321309.09185236.364141890.909
88102440.449256161.79864647.191321294.38285177.528141420.225
891024402561606464032128085120140960
90102439.560256158.24264632.967321265.93485063.736140509.890
91102439.130256156.52264626.087321252.17485008.696140069.565
92102438.710256154.83964619.355321238.71084954.839139638.710
93102438.298256153.19164612.766321225.53284902.128139217.021
94102437.895256151.57964606.316321212.63284850.526138804.211
95102437.5002561506460032120084800138400
96102437.113256148.45464593.814321187.62984750.515138004.124
97102436.735256146.93964587.755321175.51084702.041137616.327
98102436.364256145.45564581.818321163.63684654.545137236.364
991024362561446457632115284608136864
100102435.644256142.57464570.297321140.59484562.376136499.010
101102435.294256141.17664564.706321129.41284517.647136141.176
102102434.951256139.80664559.223321118.44784473.786135790.291
103102434.615256138.46264553.846321107.69284430.769135446.154
104102434.286256137.14364548.571321097.14384388.571135108.571
105102433.962256135.84964543.396321086.79284347.170134777.358
106102433.645256134.57964538.318321076.63684306.542134452.336
107102433.333256133.33364533.333321066.66784266.667134133.333
108102433.028256132.11064528.440321056.88184227.523133820.183
109102432.727256130.90964523.636321047.27384189.091133512.727
110102432.432256129.73064518.919321037.83884151.351133210.811
111102432.143256128.57164514.286321028.57184114.286132914.286
112102431.858256127.43464509.735321019.46984077.876132623.009
113102431.579256126.31664505.263321010.52684042.105132336.842
114102431.304256125.21764500.870321001.73984006.957132055.652
115102431.034256124.13864496.55232993.10383972.414131779.310
116102430.769256123.07764492.30832984.61583938.462131507.692
117102430.508256122.03464488.13632976.27183905.085131240.678
118102430.252256121.00864484.03432968.06783872.269130978.151
119102430256120644803296083840130720
120102429.752256119.00864476.03332952.06683808.264130466.116
121102429.508256118.03364472.13132944.26283777.049130216.393
122102429.268256117.07364468.29332936.58583746.341129970.732
123102429.032256116.12964464.51632929.03283716.129129729.032
124102428.800256115.20064460.80032921.60083686.400129491.200
125102428.571256114.28664457.14332914.28683657.143129257.143
126102428.346256113.38664453.54332907.08783628.346129026.772
127102428.125256112.500644503290083600128800
128102427.907256111.62864446.51232893.02383572.093128576.744
129102427.692256110.76964443.07732886.15483544.615128356.923
130102427.481256109.92464439.69532879.38983517.557128140.458
131102427.273256109.09164436.36432872.72783490.909127927.273
132102427.068256108.27164433.08332866.16583464.662127717.293
133102426.866256107.46364429.85132859.70183438.806127510.448
134102426.667256106.66764426.66732853.33383413.333127306.667
135102426.471256105.88264423.52932847.05983388.235127105.882
136102426.277256105.10964420.43832840.87683363.504126908.029
137102426.087256104.34864417.39132834.78383339.130126713.043
138102425.899256103.59764414.38832828.77783315.108126520.863
139102425.714256102.85764411.42932822.85783291.429126331.429
140102425.532256102.12864408.51132817.02183268.085126144.681
141102425.352256101.40864405.63432811.26883245.070125960.563
142102425.175256100.69964402.79732805.59483222.378125779.021
143102425256100644003280083200125600
144102424.82825699.31064397.24132794.48383177.931125423.448
145102424.65825698.63064394.52132789.04183156.164125249.315
146102424.49025697.95964391.83732783.67383134.694125077.551
147102424.32425697.29764389.18932778.37883113.514124908.108
148102424.16125696.64464386.57732773.15483092.617124740.940
14910242425696643843276883072124576
150102423.84125695.36464381.45732762.91483051.656124413.245
151102423.68425694.73764378.94732757.89583031.579124252.632
152102423.52925694.11864376.47132752.94183011.765124094.118
153102423.37725693.50664374.02632748.05282992.208123937.662
154102423.22625692.90364371.61332743.22682972.903123783.226
155102423.07725692.30864369.23132738.46282953.846123630.769
156102422.93025691.72064366.87932733.75882935.032123480.255
157102422.78525691.13964364.55732729.11482916.456123331.646
158102422.64225690.56664362.26432724.52882898.113123184.906
159102422.50025690643603272082880123040
160102422.36025689.44164357.76432715.52882862.112122896.894
161102422.22225688.88964355.55632711.11182844.444122755.556
162102422.08625688.34464353.37432706.74882826.994122615.951
163102421.95125687.80564351.22032702.43982809.756122478.049
164102421.81825687.27364349.09132698.18282792.727122341.818
165102421.68725686.74764346.98832693.97682775.904122207.229
166102421.55725686.22864344.91032689.82082759.281122074.251
167102421.42925685.71464342.85732685.71482742.857121942.857
168102421.30225685.20764340.82832681.65782726.627121813.018
169102421.17625684.70664338.82432677.64782710.588121684.706
170102421.05325684.21164336.84232673.68482694.737121557.895
171102420.93025683.72164334.88432669.76782679.070121432.558
172102420.80925683.23764332.94832665.89682663.584121308.671
173102420.69025682.75964331.03432662.06982648.276121186.207
174102420.57125682.28664329.14332658.28682633.143121065.143
175102420.45525681.81864327.27332654.54582618.182120945.455
176102420.33925681.35664325.42432650.84782603.390120827.119
177102420.22525680.89964323.59632647.19182588.764120710.112
178102420.11225680.44764321.78832643.57582574.302120594.413
17910242025680643203264082560120480
180102419.89025679.55864318.23232636.46482545.856120366.851
181102419.78025679.12164316.48432632.96782531.868120254.945
182102419.67225678.68964314.75432629.50882518.033120144.262
183102419.56525678.26164313.04332626.08782504.348120034.783
184102419.45925677.83864311.35132622.70382490.811119926.486
185102419.35525677.41964309.67732619.35582477.419119819.355
186102419.25125677.00564308.02132616.04382464.171119713.369
187102419.14925676.59664306.38332612.76682451.064119608.511
188102419.04825676.19064304.76232609.52482438.095119504.762
189102418.94725675.78964303.15832606.31682425.263119402.105
190102418.84825675.39364301.57132603.14182412.565119300.524
191102418.75025675643003260082400119200
192102418.65325674.61164298.44632596.89182387.565119100.518
193102418.55725674.22764296.90732593.81482375.258119002.062
194102418.46225673.84664295.38532590.76982363.077118904.615
195102418.36725673.46964293.87832587.75582351.020118808.163
196102418.27425673.09664292.38632584.77282339.086118712.690
197102418.18225672.72764290.90932581.81882327.273118618.182
198102418.09025672.36264289.44732578.89482315.578118524.623
19910241825672642883257682304118432
200102417.91025671.64264286.56732573.13482292.537118340.299
201102417.82225671.28764285.14932570.29782281.188118249.505
202102417.73425670.93664283.74432567.48882269.951118159.606
203102417.64725670.58864282.35332564.70682258.824118070.588
204102417.56125670.24464280.97632561.95182247.805117982.439
205102417.47625669.90364279.61232559.22382236.893117895.146
206102417.39125669.56564278.26132556.52282226.087117808.696
207102417.30825669.23164276.92332553.84682215.385117723.077
208102417.22525668.90064275.59832551.19682204.785117638.278
209102417.14325668.57164274.28632548.57182194.286117554.286
210102417.06225668.24664272.98632545.97282183.886117471.090
211102416.98125667.92564271.69832543.39682173.585117388.679
212102416.90125667.60664270.42332540.84582163.380117307.042
213102416.82225667.29064269.15932538.31882153.271117226.168
214102416.74425666.97764267.90732535.81482143.256117146.047
215102416.66725666.66764266.66732533.33382133.333117066.667
216102416.59025666.35964265.43832530.87682123.502116988.018
217102416.51425666.05564264.22032528.44082113.761116910.092
218102416.43825665.75364263.01432526.02782104.110116832.877
219102416.36425665.45564261.81832523.63682094.545116756.364
220102416.29025665.15864260.63332521.26782085.068116680.543
221102416.21625664.86564259.45932518.91982075.676116605.405
222102416.14325664.57464258.29632516.59282066.368116530.942
223102416.07125664.28664257.14332514.28682057.143116457.143
22410241625664642563251282048116384
225102415.92925663.71764254.86732509.73582038.938116311.504
226102415.85925663.43664253.74432507.48982029.956116239.648
227102415.78925663.15864252.63232505.26382021.053116168.421
228102415.72125662.88264251.52832503.05782012.227116097.817
229102415.65225662.60964250.43532500.87082003.478116027.826
230102415.58425662.33864249.35132498.70181994.805115958.442
231102415.51725662.06964248.27632496.55281986.207115889.655
232102415.45125661.80364247.21032494.42181977.682115821.459
233102415.38525661.53864246.15432492.30881969.231115753.846
234102415.31925661.27764245.10632490.21381960.851115686.809
235102415.25425661.01764244.06832488.13681952.542115620.339
236102415.19025660.75964243.03832486.07681944.304115554.430
237102415.12625660.50464242.01732484.03481936.134115489.076
238102415.06325660.25164241.00432482.00881928.033115424.268
23910241525660642403248081920115360
240102414.93825659.75164239.00432478.00881912.033115296.266
241102414.87625659.50464238.01732476.03381904.132115233.058
242102414.81525659.25964237.03732474.07481896.296115170.370
243102414.75425659.01664236.06632472.13181888.525115108.197
244102414.69425658.77664235.10232470.20481880.816115046.531
245102414.63425658.53764234.14632468.29381873.171114985.366
246102414.57525658.30064233.19832466.39781865.587114924.696
247102414.51625658.06564232.25832464.51681858.065114864.516
248102414.45825657.83164231.32532462.65181850.602114804.819
249102414.40025657.60064230.40032460.80081843.200114745.600
250102414.34325657.37164229.48232458.96481835.857114686.853
251102414.28625657.14364228.57132457.14381828.571114628.571
252102414.22925656.91764227.66832455.33681821.344114570.751
253102414.17325656.69364226.77232453.54381814.173114513.386
254102414.11825656.47164225.88232451.76581807.059114456.471
255102414.06225656.250642253245081800114400
w3cw3c
automatyka przemysłowa