Quote:
period = ($7D0 + 1) * 2 = 4002
That's the cycle delay between duty unit updates. every 4002 cycles, the duty unit will take another step. When it makes 8 steps, it completes a full wave. Therefore your following formula is off
Quote:
which is a wave at 1.79MHz / 4002 = 445
it would be 1.79MHz / (4002
* 8) = ~55.9 Hz -- a very low tone -- nowhere near middle C (you multiply by 8 because the duty unit needs to be clocked 8 times to generate one repitition of the square wave)
The tone to period formula works like so:
ToneInHz = 1789772.7272 / ( (F + 1) * 2 * 8 )
Where F is the 11-bit frequency value. Or, to work that so that you can plug in a tone and get the required F value:
F = ( 1789772.7272 / (2 * 8 * ToneInHz) ) - 1
So to do A-440, you'd write $0FD to the frequency.