Hello,
We have used the eq1, eq2 from datasheet to provision various clock rates(156-170 MHz) on my device. (1) FVCO = FREF x D x [(INT + NUM/DEN)] , (2) OUTDIV = Fvco / Fout.
To Achieve a particular frequency we have used a hard coded value of FVCO every time and programmed our device.You can find below sample code that I have used for 156.25 Mhz frequency(Here the freq is fout)
void enable_clock_modes(float freq, index i, bool status)
{
/* switch case to handle various frequencies , returns success at the end*/
switch(i)
{
case 0:
float FVCO = 5000.000 ;
unsigned int OUTDIV = (int) (FVCO / freq) ;
float DIVIDER = FVCO/REF ;
unsigned int INT = (int)DIVIDER ;
float REST = DIVIDER - INT ;
unsigned int NUM = (int)(REST * 100000); /* ideally multiplier should be 10^5, to get the exact output frequency/clock rate */
unsigned int DEN = 100000 ;
// 9-bit output divider, 8 bits from the R23(hex-17) register and 1 bit(Bit0) from R22(hex-16) register
Reg[0x16] = (OUTDIV & 0x100) >> 8 ;
Reg[0x17] = (OUTDIV & 0x0FF) ;
We are in a process to eliminate the hard coded values( FVCO ) in our code, so that customer can select any available frequency in shell to enable that particular clock frequency.To do that we need an alternate or methodology to find either OUTDIV value or FVCO value so that the other can be find out easily. My assumption was to get a way to find the OUTDIV value if output frequency is supplied, so that FVCO can be calculated and rest of the program will handle the provision of clock rates. I hope you got my requirement.
Thanks,Harish