English
Language : 

AN334 Datasheet, PDF (36/44 Pages) Silicon Laboratories – ANSI C REFERENCE DESIGN WITH OPTIONAL NON-VOLATILE OUTPUT FREQUENCY
AN334
REG[1] = (n1 & 3) << 6;
// Set N1 part of REG[1]
//Write new version of RFREQ to corresponding registers
REG[1] = REG[1] | (final_rfreq_long >> 30);
REG[2] = final_rfreq_long >> 22;
REG[3] = final_rfreq_long >> 14;
REG[4] = final_rfreq_long >> 6;
REG[5] = final_rfreq_long << 2;
/*
// Double Floating Point Precision Method
// convert new RFREQ to the binary representation
// separate the integer part
whole = FLOORF(RFREQ);
// get the binary representation of the fractional part
FRAC_BITS = FLOORF((RFREQ - whole) * POW_2_28);
// set reg 12 to 10 making frac_bits smaller by
// shifting off the last 8 bits everytime
for(i=5; i >=3; i--)
{
REG[i] = FRAC_BITS & 0xFF;
FRAC_BITS = FRAC_BITS >> 8;
}
// set the last 4 bits of the fractional portion in reg 9
REG[2] = SetBits(REG[2], 0xF0, (FRAC_BITS & 0xF));
// set the integer portion of RFREQ across reg 8 and 9
REG[2] = SetBits(REG[2], 0x0F, (whole & 0xF) << 4);
REG[1] = SetBits(REG[1], 0xC0, (whole >> 4) & 0x3F);
*/
reg137 = I2C_ByteRead(137);
// Read the current state of Register 137
I2C_ByteWrite(137, reg137 | 0x10);
for(i=0; i<6; i++)
{
I2C_ByteWrite(i+7, REG[i]);
}
// Set the Freeze DCO bit in that register
// This must be done in order to update
// Registers 7-12 on the Si57x/598/599
// Write the new values to Registers 7-12
reg137 = I2C_ByteRead(137);
// Read the current state of Register 137
I2C_ByteWrite(137, reg137 & 0xEF);
// Clear the Freeze DCO bit
I2C_ByteWrite(135, 0x40);
}
// Set the NewFreq bit to alert the DPSLL
// that a new frequency configuration
// has been applied
//-----------------------------------------------------------------------------
// SetBits
//-----------------------------------------------------------------------------
//
// Return Value : unsigned char
// Parameters :
// 1) unsigned char original - original state of variable to be changed
//
// 2) unsigned char reset_mask - contains mask of bits that will reset the
//
the original char variable.
//
// 3) unsigned char new_val - contains a mask of bits that need to be set in
36
Rev. 0.4