English
Language : 

AN123 Datasheet, PDF (10/16 Pages) Silicon Laboratories – USING THE DAC AS A FUNCTION GENERATOR
AN123
printf(“\nFREQUENCY: %ld Hz”, frequency);
printf(“\nAMPLITUDE: %d %% of VREF/2”, printed_amplitude);
EA = 0;
// Disable Interrupts to avoid
// contention between the ISR
// and the following code.
// set the frequency
phase_add = frequency * PHASE_PRECISION / SAMPLE_RATE_DAC;
break;
} // end if
}// end for
// call the associated function
f = (void *) function_table[i].function_ptr;
f();
EA = 1;
// re-enable interrupts
} // end while(1)
} // end main
//-----------------------------------------------------------------------------
// Init Routines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// SYSCLK_Init
//-----------------------------------------------------------------------------
//
// This routine initializes the system clock to use a 22.1184MHz crystal
// as its clock source.
//
void SYSCLK_Init (void)
{
int i;
// delay counter
OSCXCN = 0x67;
// start external oscillator with
// 22.1184MHz crystal
for (i=0; i < 256; i++) ;
// Wait for osc. to start up
while (!(OSCXCN & 0x80)) ;
// Wait for crystal osc. to settle
OSCICN = 0x88;
// select external oscillator as SYSCLK
// source and enable missing clock
// detector
}
//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// Configure the Crossbar and GPIO ports
10
Rev. 1.1