asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
oscillator scalar conversion for 16f15xx NCO |
Posted: Mon Mar 25, 2013 12:00 pm |
|
|
Code: |
// Efficient, 1 hz accuracy conversion to
// perform scalar correction for frequency to NCO_increment
// based on desired 2,097,152 vs actual ( 20 bit , power of 2 reference 'F' )
// versus +/- ~ 1% PIC 2mhz oscillator, gives ~ 1 hz accuracy
// for 16f15xx family NCO.
//
unsigned int16 NCOFreqtoINCR( unsigned int16 desiredfreq){
unsigned int32 t1;
t1= (unsigned int32) desiredfreq*8590;
return(t1 >>13);
}
|
the residual error is all based on the absolute accuracy of the PIC internal oscillator. converts the frequency you want based on a 2mhz int osc setting of 16f15xx part , and returns the NCO_increment value |
|