Olin Lathrop wrote: > I don't know where you got that from. Hi Olin, Well I do. :) Let me explain: My goal was not to generate 440 Hz. I posted because I thought I could help the original poster with the results of an old project. As I said in my previous post, in a past project I was using the *PWM module* and a 19.6608 MHz crystal. The duty cycle would be adjusted in firmware to be 50% no matter what the frequency was selected, and the frequency is controlled by changing the value in PR2. Thus, 256 distinct frequencies are produced over a frequency range of 300 Hz to 76,800 Hz (with some of the upper frequencies obviously beyond the range of (some) humans): If I remember correctly, I believe I ran the raw PWM output through a divide by 4 circuit (using 74xx161 ) to get the following frequencies: PR2 PWM Freq --- -------- 0 76,800.00 1 38,400.00 2 25,600.00 . . . . . . 173 441.38 174 438.86 . . . . . . 253 302.36 254 301.18 255 300.00 If you look at all 256 frequencies (see below), it is evident that that a limited portion of the table comes pretty close to the following octave in the equal-tempered chromatic scale: Note Frequency A 440.00 A# 466.16 B 493.88 C 523.25 C# 554.37 D 587.33 D# 622.25 E 659.26 F 698.46 F# 739.99 G 783.99 G# 830.61 A 880.00 My goal was not to generate 440 Hz nor a perfectly-tuned musical instrument, it was to generate frequencies in the equal-tempered scale as best I could given the 19.6608 MHz crystal. Hope this helps and clears things up. I could post the whole PWM table if you want. Best regards, Ken Pergola PR2 FREQ 86 882.76 87 872.73 88 862.92 89 853.33 90 843.96 91 834.78 92 825.81 93 817.02 94 808.42 95 800.00 96 791.75 97 783.67 98 775.76 99 768.00 100 760.40 101 752.94 102 745.63 103 738.46 104 731.43 105 724.53 106 717.76 107 711.11 108 704.59 109 698.18 110 691.89 111 685.71 112 679.65 113 673.68 114 667.83 115 662.07 116 656.41 117 650.85 118 645.38 119 640.00 120 634.71 121 629.51 122 624.39 123 619.35 124 614.40 125 609.52 126 604.72 127 600.00 128 595.35 129 590.77 130 586.26 131 581.82 132 577.44 133 573.13 134 568.89 135 564.71 136 560.58 137 556.52 138 552.52 139 548.57 140 544.68 141 540.85 142 537.06 143 533.33 144 529.66 145 526.03 146 522.45 147 518.92 148 515.44 149 512.00 150 508.61 151 505.26 152 501.96 153 498.70 154 495.48 155 492.31 156 489.17 157 486.08 158 483.02 159 480.00 160 477.02 161 474.07 162 471.17 163 468.29 164 465.45 165 462.65 166 459.88 167 457.14 168 454.44 169 451.76 170 449.12 171 446.51 172 443.93 173 441.38 174 438.86 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads