AN123 Silicon_Laboratories, AN123 Datasheet - Page 7

no-image

AN123

Manufacturer Part Number
AN123
Description
Using THE DAC AS A Function Generator
Manufacturer
Silicon_Laboratories
Datasheet
}Waveform;
typedef union lng {
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
unsigned long frequency = 1000;
unsigned int phase_add = 1000 * PHASE_PRECISION / SAMPLE_RATE_DAC;
unsigned int amplitude = 100 * 655;
Waveform output_waveform = OFF;
char input_str[16]= ““;
#define num_commands 6
Command_Table_Type code function_table[num_commands + 1] = {
};
// a full cycle, 16-bit, 2’s complement sine wave lookup table
int code SINE_TABLE[256] = {
} lng;
0x0000, 0x0324, 0x0647, 0x096a, 0x0c8b, 0x0fab, 0x12c8, 0x15e2,
0x18f8, 0x1c0b, 0x1f19, 0x2223, 0x2528, 0x2826, 0x2b1f, 0x2e11,
0x30fb, 0x33de, 0x36ba, 0x398c, 0x3c56, 0x3f17, 0x41ce, 0x447a,
0x471c, 0x49b4, 0x4c3f, 0x4ebf, 0x5133, 0x539b, 0x55f5, 0x5842,
0x5a82, 0x5cb4, 0x5ed7, 0x60ec, 0x62f2, 0x64e8, 0x66cf, 0x68a6,
0x6a6d, 0x6c24, 0x6dca, 0x6f5f, 0x70e2, 0x7255, 0x73b5, 0x7504,
0x7641, 0x776c, 0x7884, 0x798a, 0x7a7d, 0x7b5d, 0x7c29, 0x7ce3,
0x7d8a, 0x7e1d, 0x7e9d, 0x7f09, 0x7f62, 0x7fa7, 0x7fd8, 0x7ff6,
0x7fff, 0x7ff6, 0x7fd8, 0x7fa7, 0x7f62, 0x7f09, 0x7e9d, 0x7e1d,
0x7d8a, 0x7ce3, 0x7c29, 0x7b5d, 0x7a7d, 0x798a, 0x7884, 0x776c,
0x7641, 0x7504, 0x73b5, 0x7255, 0x70e2, 0x6f5f, 0x6dca, 0x6c24,
0x6a6d, 0x68a6, 0x66cf, 0x64e8, 0x62f2, 0x60ec, 0x5ed7, 0x5cb4,
0x5a82, 0x5842, 0x55f5, 0x539b, 0x5133, 0x4ebf, 0x4c3f, 0x49b4,
0x471c, 0x447a, 0x41ce, 0x3f17, 0x3c56, 0x398c, 0x36ba, 0x33de,
0x30fb, 0x2e11, 0x2b1f, 0x2826, 0x2528, 0x2223, 0x1f19, 0x1c0b,
SINE,
TRIANGLE,
SAW,
OFF
long Long;
int Int[2];
{“SQ”, Square},
{“SI”, Sine},
{“TR”, Triangle},
{“SA”, Saw},
{“OF”, Off},
{“??”, Help},
{““, Error}
// access a long variable as two
// 16-bit integer values
// frequency of output in Hz,
// defaults to 1000 Hz
// 655 is a scaling factor
// see the Timer 4 ISR
Rev. 1.1
AN123
7

Related parts for AN123