PIC24Fでは、OSCTUNレジスタを操作することによって、内蔵 FRCのクロックを 8MHz±12%まで変更することができます。また 4倍の PLLを内蔵していますので、標準のクロック 8MHz * 4 = 32MHz (Fcy = 16MHz) を超えてオーバークロック状態で動作させることができます。
これまで確認したところでは、特に目立った発熱もなく極めて安定して動作しているようです。また大変都合の良いことに、クロックを一番上まで上げた状態 (Fcy = 17.92MHz) だと、UARTのボーレート計算結果がよく、とても使いやすいです (OSCTUN and UART for PIC24F.xls)。
OpenSSMでは、OSC 8.96MHz, Fcy = 17.92MHz, Fcpu = 35.84MHz に設定しています
CLKDIVと OSCTUNレジスタを操作して、CPUクロックを変更します。また、この操作はいつでも実行できます。省電力にさせたいときはクロックを下げるなど、いろいろ使い道があります。
詳しくは、PIC24Fのデータシートを参照してください
#include <p24FJ64GA002.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & BKBUG_OFF & WINDIS_OFF & COE_OFF & ICS_PGx1 & FWDTEN_ON & WDTPS_PS256) _CONFIG2( IESO_OFF & FNOSC_FRCPLL & FCKSM_CSDCMD & OSCIOFNC_ON & IOL1WAY_OFF & I2C1SEL_PRI & POSCMOD_NONE) int main(void) { /* Fosc = 8.96MHz, Fcy = 17.92MHz, Core 35.84MHz */ CLKDIV = 0; OSCTUN = 0b0000000000011111; while(1){ ClrWdt(); } return(0); }
OSCTUN | OFFSET | FRC (Hz) | Fcy (Hz) | ||||||
0 | 1 | 1 | 1 | 1 | 1 | 31 | 0.120000 | 8,959,998 | 17,919,996 |
0 | 1 | 1 | 1 | 1 | 0 | 30 | 0.116129 | 8,929,030 | 17,858,061 |
0 | 1 | 1 | 1 | 0 | 1 | 29 | 0.112258 | 8,898,063 | 17,796,125 |
0 | 1 | 1 | 1 | 0 | 0 | 28 | 0.108387 | 8,867,095 | 17,734,190 |
0 | 1 | 1 | 0 | 1 | 1 | 27 | 0.104516 | 8,836,127 | 17,672,255 |
0 | 1 | 1 | 0 | 1 | 0 | 26 | 0.100645 | 8,805,160 | 17,610,319 |
0 | 1 | 1 | 0 | 0 | 1 | 25 | 0.096774 | 8,774,192 | 17,548,384 |
0 | 1 | 1 | 0 | 0 | 0 | 24 | 0.092903 | 8,743,224 | 17,486,449 |
0 | 1 | 0 | 1 | 1 | 1 | 23 | 0.089032 | 8,712,257 | 17,424,513 |
0 | 1 | 0 | 1 | 1 | 0 | 22 | 0.085161 | 8,681,289 | 17,362,578 |
0 | 1 | 0 | 1 | 0 | 1 | 21 | 0.081290 | 8,650,321 | 17,300,643 |
0 | 1 | 0 | 1 | 0 | 0 | 20 | 0.077419 | 8,619,354 | 17,238,707 |
0 | 1 | 0 | 0 | 1 | 1 | 19 | 0.073548 | 8,588,386 | 17,176,772 |
0 | 1 | 0 | 0 | 1 | 0 | 18 | 0.069677 | 8,557,418 | 17,114,836 |
0 | 1 | 0 | 0 | 0 | 1 | 17 | 0.065806 | 8,526,451 | 17,052,901 |
0 | 1 | 0 | 0 | 0 | 0 | 16 | 0.061935 | 8,495,483 | 16,990,966 |
0 | 0 | 1 | 1 | 1 | 1 | 15 | 0.058064 | 8,464,515 | 16,929,030 |
0 | 0 | 1 | 1 | 1 | 0 | 14 | 0.054193 | 8,433,548 | 16,867,095 |
0 | 0 | 1 | 1 | 0 | 1 | 13 | 0.050322 | 8,402,580 | 16,805,160 |
0 | 0 | 1 | 1 | 0 | 0 | 12 | 0.046452 | 8,371,612 | 16,743,224 |
0 | 0 | 1 | 0 | 1 | 1 | 11 | 0.042581 | 8,340,644 | 16,681,289 |
0 | 0 | 1 | 0 | 1 | 0 | 10 | 0.038710 | 8,309,677 | 16,619,354 |
0 | 0 | 1 | 0 | 0 | 1 | 9 | 0.034839 | 8,278,709 | 16,557,418 |
0 | 0 | 1 | 0 | 0 | 0 | 8 | 0.030968 | 8,247,741 | 16,495,483 |
0 | 0 | 0 | 1 | 1 | 1 | 7 | 0.027097 | 8,216,774 | 16,433,548 |
0 | 0 | 0 | 1 | 1 | 0 | 6 | 0.023226 | 8,185,806 | 16,371,612 |
0 | 0 | 0 | 1 | 0 | 1 | 5 | 0.019355 | 8,154,838 | 16,309,677 |
0 | 0 | 0 | 1 | 0 | 0 | 4 | 0.015484 | 8,123,871 | 16,247,741 |
0 | 0 | 0 | 0 | 1 | 1 | 3 | 0.011613 | 8,092,903 | 16,185,806 |
0 | 0 | 0 | 0 | 1 | 0 | 2 | 0.007742 | 8,061,935 | 16,123,871 |
0 | 0 | 0 | 0 | 0 | 1 | 1 | 0.003871 | 8,030,968 | 16,061,935 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000000 | 8,000,000 | 16,000,000 |
1 | 1 | 1 | 1 | 1 | 1 | -1 | -0.003750 | 7,970,000 | 15,940,000 |
1 | 1 | 1 | 1 | 1 | 0 | -2 | -0.007500 | 7,940,000 | 15,880,000 |
1 | 1 | 1 | 1 | 0 | 1 | -3 | -0.011250 | 7,910,000 | 15,820,000 |
1 | 1 | 1 | 1 | 0 | 0 | -4 | -0.015000 | 7,880,000 | 15,760,000 |
1 | 1 | 1 | 0 | 1 | 1 | -5 | -0.018750 | 7,850,000 | 15,700,000 |
1 | 1 | 1 | 0 | 1 | 0 | -6 | -0.022500 | 7,820,000 | 15,640,000 |
1 | 1 | 1 | 0 | 0 | 1 | -7 | -0.026250 | 7,790,000 | 15,580,000 |
1 | 1 | 1 | 0 | 0 | 0 | -8 | -0.030000 | 7,760,000 | 15,520,000 |
1 | 1 | 0 | 1 | 1 | 1 | -9 | -0.033750 | 7,730,000 | 15,460,000 |
1 | 1 | 0 | 1 | 1 | 0 | -10 | -0.037500 | 7,700,000 | 15,400,000 |
1 | 1 | 0 | 1 | 0 | 1 | -11 | -0.041250 | 7,670,000 | 15,340,000 |
1 | 1 | 0 | 1 | 0 | 0 | -12 | -0.045000 | 7,640,000 | 15,280,000 |
1 | 1 | 0 | 0 | 1 | 1 | -13 | -0.048750 | 7,610,000 | 15,220,000 |
1 | 1 | 0 | 0 | 1 | 0 | -14 | -0.052500 | 7,580,000 | 15,160,000 |
1 | 1 | 0 | 0 | 0 | 1 | -15 | -0.056250 | 7,550,000 | 15,100,000 |
1 | 1 | 0 | 0 | 0 | 0 | -16 | -0.060000 | 7,520,000 | 15,040,000 |
1 | 0 | 1 | 1 | 1 | 1 | -17 | -0.063750 | 7,490,000 | 14,980,000 |
1 | 0 | 1 | 1 | 1 | 0 | -18 | -0.067500 | 7,460,000 | 14,920,000 |
1 | 0 | 1 | 1 | 0 | 1 | -19 | -0.071250 | 7,430,000 | 14,860,000 |
1 | 0 | 1 | 1 | 0 | 0 | -20 | -0.075000 | 7,400,000 | 14,800,000 |
1 | 0 | 1 | 0 | 1 | 1 | -21 | -0.078750 | 7,370,000 | 14,740,000 |
1 | 0 | 1 | 0 | 1 | 0 | -22 | -0.082500 | 7,340,000 | 14,680,000 |
1 | 0 | 1 | 0 | 0 | 1 | -23 | -0.086250 | 7,310,000 | 14,620,000 |
1 | 0 | 1 | 0 | 0 | 0 | -24 | -0.090000 | 7,280,000 | 14,560,000 |
1 | 0 | 0 | 1 | 1 | 1 | -25 | -0.093750 | 7,250,000 | 14,500,000 |
1 | 0 | 0 | 1 | 1 | 0 | -26 | -0.097500 | 7,220,000 | 14,440,000 |
1 | 0 | 0 | 1 | 0 | 1 | -27 | -0.101250 | 7,190,000 | 14,380,000 |
1 | 0 | 0 | 1 | 0 | 0 | -28 | -0.105000 | 7,160,000 | 14,320,000 |
1 | 0 | 0 | 0 | 1 | 1 | -29 | -0.108750 | 7,130,000 | 14,260,000 |
1 | 0 | 0 | 0 | 1 | 0 | -30 | -0.112500 | 7,100,000 | 14,200,000 |
1 | 0 | 0 | 0 | 0 | 1 | -31 | -0.116250 | 7,070,000 | 14,140,000 |
1 | 0 | 0 | 0 | 0 | 0 | -32 | -0.120000 | 7,040,000 | 14,080,000 |
Low MODE / High MODEは、UARTの BRGHレジスタの設定を指しています。詳しくは、PIC24Fのデータシートを参照してください。
Baudrate | Fosc (MHz) | PLL | Fcy (MHz) | Low MODE | High MODE | ||||||
Calc BRG | BRG | Calc Baudrate | Error | Calc BRG | BRG | Calc Baudrate | Error | ||||
921600 | 8959998 | 2 | 17919996 | 0.215277507 | 0 | 1119999.75 | 21.528% | 3.861110026 | 4 | 895999.80 | -2.778% |
576000 | 8959998 | 2 | 17919996 | 0.94444401 | 1 | 559999.88 | -2.778% | 6.777776042 | 7 | 559999.88 | -2.778% |
500000 | 8959998 | 2 | 17919996 | 1.2399995 | 1 | 559999.88 | 12.000% | 7.959998 | 8 | 497777.67 | -0.444% |
460800 | 8959998 | 2 | 17919996 | 1.430555013 | 1 | 559999.88 | 21.528% | 8.722220052 | 9 | 447999.90 | -2.778% |
256000 | 8959998 | 2 | 17919996 | 3.374999023 | 3 | 279999.94 | 9.375% | 16.49999609 | 16 | 263529.35 | 2.941% |
250000 | 8959998 | 2 | 17919996 | 3.479999 | 3 | 279999.94 | 12.000% | 16.919996 | 17 | 248888.83 | -0.444% |
230400 | 8959998 | 2 | 17919996 | 3.861110026 | 4 | 223999.95 | -2.778% | 18.4444401 | 18 | 235789.42 | 2.339% |
153600 | 8959998 | 2 | 17919996 | 6.291665039 | 6 | 159999.96 | 4.167% | 28.16666016 | 28 | 154482.72 | 0.575% |
128000 | 8959998 | 2 | 17919996 | 7.749998047 | 8 | 124444.42 | -2.778% | 33.99999219 | 34 | 127999.97 | -0.000% |
115200 | 8959998 | 2 | 17919996 | 8.722220052 | 9 | 111999.98 | -2.778% | 37.88888021 | 38 | 114871.77 | -0.285% |
76800 | 8959998 | 2 | 17919996 | 13.58333008 | 14 | 74666.65 | -2.778% | 57.33332031 | 57 | 77241.36 | 0.575% |
64000 | 8959998 | 2 | 17919996 | 16.49999609 | 16 | 65882.34 | 2.941% | 68.99998438 | 69 | 63999.99 | -0.000% |
57600 | 8959998 | 2 | 17919996 | 18.4444401 | 18 | 58947.36 | 2.339% | 76.77776042 | 77 | 57435.88 | -0.285% |
56000 | 8959998 | 2 | 17919996 | 18.99999554 | 19 | 55999.99 | -0.000% | 78.99998214 | 79 | 55999.99 | -0.000% |
51200 | 8959998 | 2 | 17919996 | 20.87499512 | 21 | 50909.08 | -0.568% | 86.49998047 | 86 | 51494.24 | 0.575% |
38400 | 8959998 | 2 | 17919996 | 28.16666016 | 28 | 38620.68 | 0.575% | 115.6666406 | 116 | 38290.59 | -0.285% |
28800 | 8959998 | 2 | 17919996 | 37.88888021 | 38 | 28717.94 | -0.285% | 154.5555208 | 155 | 28717.94 | -0.285% |
19200 | 8959998 | 2 | 17919996 | 57.33332031 | 57 | 19310.34 | 0.575% | 232.3332813 | 232 | 19227.46 | 0.143% |
16000 | 8959998 | 2 | 17919996 | 68.99998438 | 69 | 16000.00 | -0.000% | 278.9999375 | 279 | 16000.00 | -0.000% |
14400 | 8959998 | 2 | 17919996 | 76.77776042 | 77 | 14358.97 | -0.285% | 310.1110417 | 310 | 14405.14 | 0.036% |
9600 | 8959998 | 2 | 17919996 | 115.6666406 | 116 | 9572.65 | -0.285% | 465.6665625 | 466 | 9593.15 | -0.071% |
7200 | 8959998 | 2 | 17919996 | 154.5555208 | 155 | 7179.49 | -0.285% | 621.2220833 | 621 | 7202.57 | 0.036% |
4800 | 8959998 | 2 | 17919996 | 232.3332813 | 232 | 4806.87 | 0.143% | 932.333125 | 932 | 4801.71 | 0.036% |
4000 | 8959998 | 2 | 17919996 | 278.9999375 | 279 | 4000.00 | -0.000% | 1118.99975 | 1119 | 4000.00 | -0.000% |
2400 | 8959998 | 2 | 17919996 | 465.6665625 | 466 | 2398.29 | -0.071% | 1865.66625 | 1866 | 2399.57 | -0.018% |
1800 | 8959998 | 2 | 17919996 | 621.2220833 | 621 | 1800.64 | 0.036% | 2487.888333 | 2488 | 1799.92 | -0.004% |
1200 | 8959998 | 2 | 17919996 | 932.333125 | 932 | 1200.43 | 0.036% | 3732.3325 | 3732 | 1200.11 | 0.009% |
600 | 8959998 | 2 | 17919996 | 1865.66625 | 1866 | 599.89 | -0.018% | 7465.665 | 7466 | 599.97 | -0.004% |
300 | 8959998 | 2 | 17919996 | 3732.3325 | 3732 | 300.03 | 0.009% | 14932.33 | 14932 | 300.01 | 0.002% |