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: 4000000 Hz
OCR2  Prescaler Freq. Prescaler Freq. Prescaler Freq. Prescaler Freq. Prescaler Freq. Prescaler Freq. 
010243906.25025615625646250032125000850000014000000
110241953.1252567812.50064312503262500825000012000000
210241302.0832565208.3336420833.3333241666.6678166666.66711333333.333
31024976.5622563906.25064156253231250812500011000000
41024781.25025631256412500322500081000001800000
51024651.0422562604.1676410416.6673220833.333883333.3331666666.667
61024558.0362562232.143648928.5713217857.143871428.5711571428.571
71024488.2812561953.125647812.50032156258625001500000
81024434.0282561736.111646944.4443213888.889855555.5561444444.444
91024390.6252561562.50064625032125008500001400000
101024355.1142561420.455645681.8183211363.636845454.5451363636.364
111024325.5212561302.083645208.3333210416.667841666.6671333333.333
121024300.4812561201.923644807.692329615.385838461.5381307692.308
131024279.0182561116.071644464.286328928.571835714.2861285714.286
141024260.4172561041.667644166.667328333.333833333.3331266666.667
151024244.141256976.562643906.250327812.5008312501250000
161024229.779256919.118643676.471327352.941829411.7651235294.118
171024217.014256868.056643472.222326944.444827777.7781222222.222
181024205.592256822.368643289.474326578.947826315.7891210526.316
191024195.312256781.2506431253262508250001200000
201024186.012256744.048642976.190325952.381823809.5241190476.190
211024177.557256710.227642840.909325681.818822727.2731181818.182
221024169.837256679.348642717.391325434.783821739.1301173913.043
231024162.760256651.042642604.167325208.333820833.3331166666.667
241024156.2502566256425003250008200001160000
251024150.240256600.962642403.846324807.692819230.7691153846.154
261024144.676256578.704642314.815324629.630818518.5191148148.148
271024139.509256558.036642232.143324464.286817857.1431142857.143
281024134.698256538.793642155.172324310.345817241.3791137931.034
291024130.208256520.833642083.333324166.667816666.6671133333.333
301024126.008256504.032642016.129324032.258816129.0321129032.258
311024122.070256488.281641953.125323906.2508156251125000
321024118.371256473.485641893.939323787.879815151.5151121212.121
331024114.890256459.559641838.235323676.471814705.8821117647.059
341024111.607256446.429641785.714323571.429814285.7141114285.714
351024108.507256434.028641736.111323472.222813888.8891111111.111
361024105.574256422.297641689.189323378.378813513.5141108108.108
371024102.796256411.184641644.737323289.474813157.8951105263.158
381024100.160256400.641641602.564323205.128812820.5131102564.103
39102497.656256390.625641562.5003231258125001100000
40102495.274256381.098641524.390323048.780812195.122197560.976
41102493.006256372.024641488.095322976.190811904.762195238.095
42102490.843256363.372641453.488322906.977811627.907193023.256
43102488.778256355.114641420.455322840.909811363.636190909.091
44102486.806256347.222641388.889322777.778811111.111188888.889
45102484.918256339.674641358.696322717.391810869.565186956.522
46102483.112256332.447641329.787322659.574810638.298185106.383
47102481.380256325.521641302.083322604.167810416.667183333.333
48102479.719256318.878641275.510322551.020810204.082181632.653
49102478.125256312.500641250322500810000180000
50102476.593256306.373641225.490322450.98089803.922178431.373
51102475.120256300.481641201.923322403.84689615.385176923.077
52102473.703256294.811641179.245322358.49189433.962175471.698
53102472.338256289.352641157.407322314.81589259.259174074.074
54102471.023256284.091641136.364322272.72789090.909172727.273
55102469.754256279.018641116.071322232.14388928.571171428.571
56102468.531256274.123641096.491322192.98288771.930170175.439
57102467.349256269.397641077.586322155.17288620.690168965.517
58102466.208256264.831641059.322322118.64488474.576167796.610
59102465.104256260.417641041.667322083.33388333.333166666.667
60102464.037256256.148641024.590322049.18088196.721165573.770
61102463.004256252.016641008.065322016.12988064.516164516.129
62102462.004256248.01664992.063321984.12787936.508163492.063
63102461.035256244.14164976.562321953.12587812.500162500
64102460.096256240.38564961.538321923.07787692.308161538.462
65102459.186256236.74264946.970321893.93987575.758160606.061
66102458.302256233.20964932.836321865.67287462.687159701.493
67102457.445256229.77964919.118321838.23587352.941158823.529
68102456.612256226.44964905.797321811.59487246.377157971.014
69102455.804256223.21464892.857321785.71487142.857157142.857
70102455.018256220.07064880.282321760.56387042.254156338.028
71102454.253256217.01464868.056321736.11186944.444155555.556
72102453.510256214.04164856.164321712.32986849.315154794.521
73102452.787256211.14964844.595321689.18986756.757154054.054
74102452.083256208.33364833.333321666.66786666.667153333.333
75102451.398256205.59264822.368321644.73786578.947152631.579
76102450.731256202.92264811.688321623.37786493.506151948.052
77102450.080256200.32164801.282321602.56486410.256151282.051
78102449.446256197.78564791.139321582.27886329.114150632.911
79102448.828256195.31264781.250321562.50086250150000
80102448.225256192.90164771.605321543.21086172.840149382.716
81102447.637256190.54964762.195321524.39086097.561148780.488
82102447.063256188.25364753.012321506.02486024.096148192.771
83102446.503256186.01264744.048321488.09585952.381147619.048
84102445.956256183.82464735.294321470.58885882.353147058.824
85102445.422256181.68664726.744321453.48885813.953146511.628
86102444.899256179.59864718.391321436.78285747.126145977.011
87102444.389256177.55764710.227321420.45585681.818145454.545
88102443.890256175.56264702.247321404.49485617.978144943.820
89102443.403256173.61164694.444321388.88985555.556144444.444
90102442.926256171.70364686.813321373.62685494.505143956.044
91102442.459256169.83764679.348321358.69685434.783143478.261
92102442.003256168.01164672.043321344.08685376.344143010.753
93102441.556256166.22364664.894321329.78785319.149142553.191
94102441.118256164.47464657.895321315.78985263.158142105.263
95102440.690256162.76064651.042321302.08385208.333141666.667
96102440.271256161.08264644.330321288.66085154.639141237.113
97102439.860256159.43964637.755321275.51085102.041140816.327
98102439.457256157.82864631.313321262.62685050.505140404.040
99102439.062256156.2506462532125085000140000
100102438.676256154.70364618.812321237.62484950.495139603.960
101102438.297256153.18664612.745321225.49084901.961139215.686
102102437.925256151.69964606.796321213.59284854.369138834.951
103102437.560256150.24064600.962321201.92384807.692138461.538
104102437.202256148.81064595.238321190.47684761.905138095.238
105102436.851256147.40664589.623321179.24584716.981137735.849
106102436.507256146.02864584.112321168.22484672.897137383.178
107102436.169256144.67664578.704321157.40784629.630137037.037
108102435.837256143.34964573.394321146.78984587.156136697.248
109102435.511256142.04564568.182321136.36484545.455136363.636
110102435.191256140.76664563.063321126.12684504.505136036.036
111102434.877256139.50964558.036321116.07184464.286135714.286
112102434.569256138.27464553.097321106.19584424.779135398.230
113102434.265256137.06164548.246321096.49184385.965135087.719
114102433.967256135.87064543.478321086.95784347.826134782.609
115102433.675256134.69864538.793321077.58684310.345134482.759
116102433.387256133.54764534.188321068.37684273.504134188.034
117102433.104256132.41564529.661321059.32284237.288133898.305
118102432.826256131.30364525.210321050.42084201.681133613.445
119102432.552256130.20864520.833321041.66784166.667133333.333
120102432.283256129.13264516.529321033.05884132.231133057.851
121102432.018256128.07464512.295321024.59084098.361132786.885
122102431.758256127.03364508.130321016.26084065.041132520.325
123102431.502256126.00864504.032321008.06584032.258132258.065
124102431.2502561256450032100084000132000
125102431.002256124.00864496.03232992.06383968.254131746.032
126102430.758256123.03164492.12632984.25283937.008131496.063
127102430.518256122.07064488.28132976.56283906.250131250
128102430.281256121.12464484.49632968.99283875.969131007.752
129102430.048256120.19264480.76932961.53883846.154130769.231
130102429.819256119.27564477.09932954.19883816.794130534.351
131102429.593256118.37164473.48532946.97083787.879130303.030
132102429.370256117.48164469.92532939.85083759.398130075.188
133102429.151256116.60464466.41832932.83683731.343129850.746
134102428.935256115.74164462.96332925.92683703.704129629.630
135102428.722256114.89064459.55932919.11883676.471129411.765
136102428.513256114.05164456.20432912.40983649.635129197.080
137102428.306256113.22564452.89932905.79783623.188128985.507
138102428.103256112.41064449.64032899.28183597.122128776.978
139102427.902256111.60764446.42932892.85783571.429128571.429
140102427.704256110.81664443.26232886.52583546.099128368.794
141102427.509256110.03564440.14132880.28283521.127128169.014
142102427.316256109.26664437.06332874.12683496.503127972.028
143102427.127256108.50764434.02832868.05683472.222127777.778
144102426.940256107.75964431.03432862.06983448.276127586.207
145102426.755256107.02164428.08232856.16483424.658127397.260
146102426.573256106.29364425.17032850.34083401.361127210.884
147102426.394256105.57464422.29732844.59583378.378127027.027
148102426.216256104.86664419.46332838.92683355.705126845.638
149102426.042256104.16764416.66732833.33383333.333126666.667
150102425.869256103.47764413.90732827.81583311.258126490.066
151102425.699256102.79664411.18432822.36883289.474126315.789
152102425.531256102.12464408.49732816.99383267.974126143.791
153102425.365256101.46164405.84432811.68883246.753125974.026
154102425.202256100.80664403.22632806.45283225.806125806.452
155102425.040256100.16064400.64132801.28283205.128125641.026
156102424.88125699.52264398.08932796.17883184.713125477.707
157102424.72325698.89264395.57032791.13983164.557125316.456
158102424.56825698.27064393.08232786.16483144.654125157.233
159102424.41425697.65664390.62532781.25083125125000
160102424.26225697.05064388.19932776.39883105.590124844.720
161102424.11325696.45164385.80232771.60583086.420124691.358
162102423.96525695.85964383.43632766.87183067.485124539.877
163102423.81925695.27464381.09832762.19583048.780124390.244
164102423.67425694.69764378.78832757.57683030.303124242.424
165102423.53225694.12764376.50632753.01283012.048124096.386
166102423.39125693.56364374.25132748.50382994.012123952.096
167102423.25125693.00664372.02432744.04882976.190123809.524
168102423.11425692.45664369.82232739.64582958.580123668.639
169102422.97825691.91264367.64732735.29482941.176123529.412
170102422.84425691.37464365.49732730.99482923.977123391.813
171102422.71125690.84364363.37232726.74482906.977123255.814
172102422.57925690.31864361.27232722.54382890.173123121.387
173102422.45025689.79964359.19532718.39182873.563122988.506
174102422.32125689.28664357.14332714.28682857.143122857.143
175102422.19525688.77864355.11432710.22782840.909122727.273
176102422.06925688.27764353.10732706.21582824.859122598.870
177102421.94525687.78164351.12432702.24782808.989122471.910
178102421.82325687.29164349.16232698.32482793.296122346.369
179102421.70125686.80664347.22232694.44482777.778122222.222
180102421.58125686.32664345.30432690.60882762.431122099.448
181102421.46325685.85264343.40732686.81382747.253121978.022
182102421.34625685.38364341.53032683.06082732.240121857.923
183102421.23025684.91864339.67432679.34882717.391121739.130
184102421.11525684.45964337.83832675.67682702.703121621.622
185102421.00125684.00564336.02232672.04382688.172121505.376
186102420.88925683.55664334.22532668.44982673.797121390.374
187102420.77825683.11264332.44732664.89482659.574121276.596
188102420.66825682.67264330.68832661.37682645.503121164.021
189102420.55925682.23764328.94732657.89582631.579121052.632
190102420.45225681.80664327.22532654.45082617.801120942.408
191102420.34525681.38064325.52132651.04282604.167120833.333
192102420.24025680.95964323.83432647.66882590.674120725.389
193102420.13525680.54164322.16532644.33082577.320120618.557
194102420.03225680.12864320.51332641.02682564.103120512.821
195102419.93025679.71964318.87832637.75582551.020120408.163
196102419.82925679.31564317.25932634.51882538.071120304.569
197102419.72925678.91464315.65732631.31382525.253120202.020
198102419.62925678.51864314.07032628.14182512.563120100.503
199102419.53125678.12564312.5003262582500120000
200102419.43425677.73664310.94532621.89182487.562119900.498
201102419.33825677.35164309.40632618.81282475.248119801.980
202102419.24325676.97064307.88232615.76482463.054119704.433
203102419.14825676.59364306.37332612.74582450.980119607.843
204102419.05525676.22064304.87832609.75682439.024119512.195
205102418.96225675.85064303.39832606.79682427.184119417.476
206102418.87125675.48364301.93232603.86582415.459119323.671
207102418.78025675.12064300.48132600.96282403.846119230.769
208102418.69025674.76164299.04332598.08682392.344119138.756
209102418.60125674.40564297.61932595.23882380.952119047.619
210102418.51325674.05264296.20932592.41782369.668118957.346
211102418.42625673.70364294.81132589.62382358.491118867.925
212102418.33925673.35764293.42732586.85482347.418118779.343
213102418.25425673.01464292.05632584.11282336.449118691.589
214102418.16925672.67464290.69832581.39582325.581118604.651
215102418.08425672.33864289.35232578.70482314.815118518.519
216102418.00125672.00564288.01832576.03782304.147118433.180
217102417.91925671.67464286.69732573.39482293.578118348.624
218102417.83725671.34764285.38832570.77682283.105118264.840
219102417.75625671.02364284.09132568.18282272.727118181.818
220102417.67525670.70164282.80532565.61182262.443118099.548
221102417.59625670.38364281.53232563.06382252.252118018.018
222102417.51725670.06764280.26932560.53882242.152117937.220
223102417.43925669.75464279.01832558.03682232.143117857.143
224102417.36125669.44464277.77832555.55682222.222117777.778
225102417.28425669.13764276.54932553.09782212.389117699.115
226102417.20825668.83364275.33032550.66182202.643117621.145
227102417.13325668.53164274.12332548.24682192.982117543.860
228102417.05825668.23164272.92632545.85282183.406117467.249
229102416.98425667.93564271.73932543.47882173.913117391.304
230102416.91025667.64164270.56332541.12682164.502117316.017
231102416.83725667.34964269.39732538.79382155.172117241.379
232102416.76525667.06064268.24032536.48182145.923117167.382
233102416.69325666.77464267.09432534.18882136.752117094.017
234102416.62225666.48964265.95732531.91582127.660117021.277
235102416.55225666.20864264.83132529.66182118.644116949.153
236102416.48225665.92864263.71332527.42682109.705116877.637
237102416.41325665.65164262.60532525.21082100.840116806.723
238102416.34425665.37764261.50632523.01382092.050116736.402
239102416.27625665.10464260.41732520.83382083.333116666.667
240102416.20925664.83464259.33632518.67282074.689116597.510
241102416.14225664.56664258.26432516.52982066.116116528.926
242102416.07525664.30064257.20232514.40382057.613116460.905
243102416.00925664.03764256.14832512.29582049.180116393.443
244102415.94425663.77664255.10232510.20482040.816116326.531
245102415.87925663.51664254.06532508.13082032.520116260.163
246102415.81525663.25964253.03632506.07382024.291116194.332
247102415.75125663.00464252.01632504.03282016.129116129.032
248102415.68825662.75164251.00432502.00882008.032116064.257
249102415.62525662.500642503250082000116000
250102415.56325662.25164249.00432498.00881992.032115936.255
251102415.50125662.00464248.01632496.03281984.127115873.016
252102415.44025661.75964247.03632494.07181976.285115810.277
253102415.37925661.51664246.06332492.12681968.504115748.031
254102415.31925661.27564245.09832490.19681960.784115686.275
255102415.25925661.03564244.14132488.28181953.125115625
w3cw3c
automatyka przemysłowa