NCO settings calculator - Unexpected result
Rayman
Posts: 14,640
in Propeller 2
I coded up a calculator to help pick WXPIN and WYPIN settings for NCO Frequency smart pin mode.
Was thinking that the WXPIN setting is totally useless because my calculator was always telling me that the best setting was WXPIN=1.
This is with P2 frequency equals 160 MHz.
But while testing, when I put in 2 MHz for desired frequency, I got 5 for the best WXPIN setting.
See this screenshot for 200 kHz result.
Seems very strange, but maybe correct?
Comments
Here's my simple code to calculate WXPIN and WYPIN settings in C++.
It's just brute force looking for a better WXPIN... Maybe there's a better way?
Yes that is correct:
160 / 2 = 80, so we need 1/80 of sysclock
80 = 5 * 16, so if you divide by 5 the phase accumulator of the NCO must divide by 16, which is exactly possible, while 1/80 is not exact possible, only 1 / 80.000000298...
Andy