mrfioc2  2.3.0
FracSynthAnalyze.c
Go to the documentation of this file.
1 /**************************************************************************************************
2 |* FracSynthAnalyze () -- Analyze a Micrel SY87739L Fractional Synthesizer Control Word
3 |*
4 |*--------------------------------------------------------------------------------------------------
5 |* Author: Eric Bjorklund (LANSCE)
6 |* Date: 13 September 2006
7 |*
8 |*--------------------------------------------------------------------------------------------------
9 |* MODIFICATION HISTORY:
10 |* 13 Sep 2006 E.Bjorklund Original Release
11 |*
12 |*--------------------------------------------------------------------------------------------------
13 |* REFERENCE:
14 |* Micrel SY87739L Product Description. Available at:
15 |* http://www.micrel.com
16 |*
17 |*--------------------------------------------------------------------------------------------------
18 |* MODULE DESCRIPTION:
19 |*
20 |* This function will take a hexadecimal number representing an SY87739L fractional synthesizer
21 |* control word and display the effective values of its six components. These are:
22 |*
23 |* P: The integer part of the fractional frequency.
24 |* Q(p): The number of times to divide by P in the fractional-N control circuit.
25 |* Q(p-1): The number of times to divide by P-1 in the fractional-N control circuit.
26 |* PostDivide: The final post-divider.
27 |* N: The numerator of the correction term.
28 |* M: The denominator of the correction term.
29 |*
30 |* It also displays the effective frequency of the internal Voltage-Controlled-Oscillator (VCO)
31 |* and the final output frequency that the control word will produce.
32 |*
33 |* The control word is also analyzed for programming errors and will display any problems it
34 |* finds.
35 |*
36 |*-------------------------------------------------------------------------------------------------
37 |* USAGE:
38 |* FracSynthAnalyze <ControlWord>
39 |*
40 |*-------------------------------------------------------------------------------------------------
41 |* INPUT PARAMETERS:
42 |* ControlWord = (unsigned long) Hexadecimal representation of the Micrel SY87739L
43 |* control word to be analyzed.
44 |*
45 |*-------------------------------------------------------------------------------------------------
46 |* RETURNS:
47 |* Always returns 0 (OK).
48 |*
49 \**************************************************************************************************/
50 
51 /**************************************************************************************************
52 |* COPYRIGHT NOTIFICATION
53 |**************************************************************************************************
54 |*
55 |* THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE,
56 |* AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE
57 |* AND IN ALL SOURCE LISTINGS OF THE CODE.
58 |*
59 |**************************************************************************************************
60 |*
61 |* Copyright (c) 2006 Los Alamos National Security, LLC
62 |* as Operator of Los Alamos National Laboratory.
63 |*
64 |**************************************************************************************************
65 |*
66 |* This software is distributed under the EPICS Open License Agreement which
67 |* can be found in the file, LICENSE, included with this distribution.
68 |*
69 \*************************************************************************************************/
70 
71 /**************************************************************************************************/
72 /* Imported Header Files */
73 /**************************************************************************************************/
74 
75 #include <stdlib.h> /* Standard C utility routines and definitions */
76 #include <stdio.h> /* Standard C I/O library */
77 #include <errno.h> /* Standard C errno defintions */
78 
79 #include <epicsTypes.h> /* EPICS type definitions */
80 
81 #include <mrfCommon.h> /* MRF common definitions */
82 
83 #ifdef _WIN32
84  #include <mrfFracSynth.h> /* MRF SY87739L control word creation & analysis prototypes */
85 #endif
86 #include <debugPrint.h> /* SLAC Debug print utility */
87 
88 #include <epicsExport.h> /* EPICS Symbol exporting macro definitions */
89 
90 /**************************************************************************************************/
91 /* Import the Fractional Synthesizer Utility Routines */
92 /**************************************************************************************************/
93 
94 #define HOST_BUILD
95 
96 #ifndef _WIN32
97 # include <mrfFracSynth.h> /* MRF SY87739L control word creation & analysis prototypes */
98 # include <mrfFracSynth.c> /* MRF SY87739L control word creation & analysis routines */
99 #endif
100 /**************************************************************************************************/
101 /* Main Program */
102 /**************************************************************************************************/
103 
104 int main (int argc, char *argv[]) {
105 
106  /*---------------------
107  * Local Variables
108  */
109  int badArgs = 1; /* True if we could not parse the argument list */
110  epicsUInt32 controlWord; /* SY87739L control word to analyze */
111  char *tailPtr; /* Pointer to tail of parsed control word string */
112 
113  /*---------------------
114  * Make sure we were passed only one argument.
115  * If so, see if we can parse it as a hexadecimal number.
116  */
117  if (argc == 2) {
118  controlWord = strtoul (argv[1], &tailPtr, 16);
119 
120  /*---------------------
121  * If we successfully parsed the control word,
122  * analyze it and display the results.
123  */
124  if ((errno == OK) && (tailPtr != argv[1])) {
126  badArgs = 0;
127  }/*end if control word parse was successful*/
128 
129  }/*end if we had the right number of arguments*/
130 
131  /*---------------------
132  * Print the "Usage" message if we could not parse the argument.
133  */
134  if (badArgs) {
135  printf ("Usage:\n");
136  printf ("FracSynthAnalyze <ControlWord>\n");
137  printf (" Where <ControlWord> is a hexadecimal number representing\n");
138  printf (" a Micrel SY87739L control word to be analyzed.\n");
139  }/*end if could not parse arguments*/
140 
141  /*---------------------
142  * Always return success.
143  */
144  return OK;
145 
146 }/*end main()*/
int main(int argc, char *argv[])
#define OK
Definition: mrfFracSynth.h:81
#define MRF_FRAC_SYNTH_REF
Definition: mrfCommon.h:99
epicsShareExtern epicsFloat64 FracSynthAnalyze(epicsUInt32 ControlWord, epicsFloat64 ReferenceFreq, epicsInt32 PrintFlag)
Definition: mrfFracSynth.c:844
Support routines for the Micrel SY87739L Fractional-N Synthesizer.
#define DP_DEBUG
Definition: debugPrint.h:93