Created
January 6, 2022 17:40
-
-
Save AliBarber/13645cec3cbdb354b82341893438f22f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <math.h> | |
using namespace std; | |
int main(int argc, char **argv){ | |
if(argc != 2){ | |
cout << "Usage:\n" << argv[0] << "\t BASE_FREQUENCY" << endl; | |
return 1; | |
} | |
long clock_freq = 75000000; | |
long base_frequency = atof(argv[1]); | |
const float shift = 1.46484375; | |
for(int i = 0; i < 4; i++){ | |
long frequency = base_frequency + (i * shift); | |
long freq_reg = (frequency * pow(2,28)) / clock_freq; | |
uint16_t MSB, LSB; | |
LSB = freq_reg & 0x3FFF; // 14 LSBs | |
MSB = ((freq_reg & 0xFFFC000) >> 14); | |
cout << MSB << "," << LSB << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment