44 lines
963 B
C
44 lines
963 B
C
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
uint32_t si5351_freq_a = 400000000;
|
|
uint32_t freq_xtal = 25000000;
|
|
uint32_t out_freq = 10000000;
|
|
|
|
|
|
double fdiv = (double) si5351_freq_a / (double) freq_xtal;
|
|
|
|
//TODO: Find better way to determine c and b
|
|
uint32_t c = 0x0FFFFF;
|
|
uint32_t a = (uint32_t) fdiv;
|
|
double rm = fdiv - a;
|
|
uint32_t b = rm * c;
|
|
|
|
printf("%u + %u / %u\n", a, b, c);
|
|
|
|
uint32_t p1 = 128 * a + (128 * b / c) - 512;
|
|
uint32_t p2 = 128 * b - c * (128 * b / c);
|
|
uint32_t p3 = c;
|
|
|
|
printf("%u %u %u\n", p1, p2, p3);
|
|
|
|
fdiv = (double) si5351_freq_a / (double) out_freq;
|
|
|
|
//TODO: Find better way to determine c and b
|
|
c = 0x0FFFFF;
|
|
a = (uint32_t) fdiv;
|
|
rm = fdiv - a;
|
|
b = rm * c;
|
|
|
|
printf("%u + %u / %u\n", a, b, c);
|
|
|
|
p1 = 128 * a + (128 * b / c) - 512;
|
|
p2 = 128 * b - c * (128 * b / c);
|
|
p3 = c;
|
|
|
|
printf("%u %u %u\n", p1, p2, p3);
|
|
|
|
return 0;
|
|
}
|