mrfioc2  2.3.0
Classes | Macros | Functions
mrfFracSynth.c File Reference

Support routines for the Micrel SY87739L Fractional-N Synthesizer. More...

#include <stdio.h>
#include <math.h>
#include <epicsTypes.h>
#include <iocsh.h>
#include <registryFunction.h>
#include <epicsExport.h>
#include <mrfFracSynth.h>
#include <mrfCommon.h>
#include <debugPrint.h>
Include dependency graph for mrfFracSynth.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PostDivideStruct
 
struct  CorrectionStruct
 
struct  CorrectionValStruct
 
struct  FracSynthComponents
 

Macros

#define DEBUG_PRINT   /* Debug printing always enabled for this module */
 
#define MAX_CORRECTION_RATIO   (17./14.) /* Maximum value for correction term. */
 
#define MAX_VCO_FREQ   729.0 /* Maximum frequency for voltage-controlled oscillator */
 
#define MIN_VCO_FREQ   540.0 /* Minimum frequency for voltage-controlled oscillator */
 
#define MIN_P_VALUE   17 /* Minimum val for integer part of fractional frequency */
 
#define MAX_FRAC_DIVISOR   31 /* Maximum divisor for fractional frequency value */
 
#define NUM_POST_DIVIDES   31 /* Number of unique post-divider values */
 
#define NUM_POST_DIVIDE_VALS   32 /* Number of post-divider codes */
 
#define NUM_CORRECTIONS   23 /* Number of valid correction values (plus one) */
 
#define NUM_CORRECTION_VALS   8 /* Number of correction value codes */
 
#define MAX_ERROR   100.0 /* Artifical error maximum */
 
#define ZERO_THRESHOLD   1.0e-9 /* Floating point threshold for zero detection */
 
#define CONTROL_MDIV_BITS   3 /* Denominator of correction term */
 
#define CONTROL_NDIV_BITS   3 /* Numerator of correction term */
 
#define CONTROL_POSTDIV_BITS   5 /* Post-Divider */
 
#define CONTROL_MFG_BITS   3 /* Must Be Zero */
 
#define CONTROL_P_BITS   4 /* Integer part of fractional frequency */
 
#define CONTROL_QPM1_BITS   5 /* Value for Q(p-1) term of fractional frequency */
 
#define CONTROL_QP_BITS   5 /* Value for Q(p) term of fractional frequency */
 
#define CONTROL_PREAMBLE_BITS   4 /* Must Be Zero */
 
#define CONTROL_MDIV_SHIFT   0 /* Denominator of correction term */
 
#define CONTROL_NDIV_SHIFT   3 /* Numerator of correction term */
 
#define CONTROL_POSTDIV_SHIFT   6 /* Post-Divider */
 
#define CONTROL_MFG_SHIFT   11 /* Must Be Zero */
 
#define CONTROL_P_SHIFT   14 /* Integer part of fractional frequency */
 
#define CONTROL_QPM1_SHIFT   18 /* Value for Q(p-1) term of fractional frequency */
 
#define CONTROL_QP_SHIFT   23 /* Value for Q(p) term of fractional frequency */
 
#define CONTROL_PREAMBLE_SHIFT   28 /* Must Be Zero */
 
#define CONTROL_MDIV_MASK   (((1 << CONTROL_MDIV_BITS) - 1) << CONTROL_MDIV_SHIFT)
 
#define CONTROL_NDIV_MASK   (((1 << CONTROL_NDIV_BITS) - 1) << CONTROL_NDIV_SHIFT)
 
#define CONTROL_POSTDIV_MASK   (((1 << CONTROL_POSTDIV_BITS) - 1) << CONTROL_POSTDIV_SHIFT)
 
#define CONTROL_MFG_MASK   (((1 << CONTROL_MFG_BITS) - 1) << CONTROL_MFG_SHIFT)
 
#define CONTROL_P_MASK   (((1 << CONTROL_P_BITS) - 1) << CONTROL_P_SHIFT)
 
#define CONTROL_QPM1_MASK   (((1 << CONTROL_QPM1_BITS) - 1) << CONTROL_QPM1_SHIFT)
 
#define CONTROL_QP_MASK   (((1 << CONTROL_QP_BITS) - 1) << CONTROL_QP_SHIFT)
 
#define CONTROL_PREAMBLE_MASK   (((1 << CONTROL_PREAMBLE_BITS) - 1) << CONTROL_PREAMBLE_SHIFT)
 
#define CORRECTION_DIV_14   5 /* Numerator or denominator of 14 */
 
#define CORRECTION_DIV_15   7 /* Numerator or denominator of 15 */
 
#define CORRECTION_DIV_16   1 /* Numerator or denominator of 16 */
 
#define CORRECTION_DIV_17   3 /* Numerator or denominator of 17 */
 
#define CORRECTION_DIV_18   2 /* Numerator or denominator of 18 */
 
#define CORRECTION_DIV_31   4 /* Numerator or denominator of 31 */
 
#define CORRECTION_DIV_32   6 /* Numerator or denominator of 32 */
 

Functions

epicsShareExtern epicsStatus mrfSetEventClockSpeed (epicsFloat64 InputClockSpeed, epicsUInt32 InputControlWord, epicsFloat64 ReferenceFreq, epicsFloat64 *OutputClockSpeed, epicsUInt32 *OutputControlWord, epicsInt32 PrintFlag)
 
epicsShareExtern epicsUInt32 FracSynthControlWord (epicsFloat64 DesiredFreq, epicsFloat64 ReferenceFreq, epicsInt32 debugFlag, epicsFloat64 *Error)
 
epicsShareExtern epicsFloat64 FracSynthAnalyze (epicsUInt32 ControlWord, epicsFloat64 ReferenceFreq, epicsInt32 PrintFlag)
 
 epicsExportRegistrar (FracSynthRegistrar)
 

Detailed Description

Support routines for the Micrel SY87739L Fractional-N Synthesizer.

This module contains routines to create and analyze the control word for the Micrel SY87739L Fractional-N synthesizer chip. This chip is used in the MRF Series-200 event receiver cards to synchronize with the expected event clock frequency. It is also in the event generator card where it can be used to generate the event clock in the absence of an RF source.

Three routines are provided in this module:

For convenience, this module also defines EPICS IOC Shell versions of the "FracSynth" routines. The IOC Shell versions only take the first argument. The reference frequency defaults to the MRF input reference frequency (24 MHz) and the debugFlag/PrintFlag are defaulted to produce the maximum amount of printed output.

Note
For the MRF Series-2xx cards, the input reference frequency is 24 Mhz.
To use the EPICS IOC shell definitions, the "Data Base Definition" (dbd) file should include the line:
"registrar(FracSynthRegistrar)"
These routines are not suitable for calling from the vxWorks shell as they require floating point input.

Definition in file mrfFracSynth.c.