AN123 Silicon_Laboratories, AN123 Datasheet - Page 14

no-image

AN123

Manufacturer Part Number
AN123
Description
Using THE DAC AS A Function Generator
Manufacturer
Silicon_Laboratories
Datasheet
AN123
14
int code *table_ptr;
lng temporary_long;
T4CON &= ~0x80;
table_ptr = SINE_TABLE;
phase_acc += phase_add;
// set the value of <temp1> to the next output of DAC1 at full-scale
// amplitude; the
switch (output_waveform){
case SINE:
case SQUARE:
case TRIANGLE:
case SAW:
case OFF:
// read the table value
temp1 = *(table_ptr + (phase_acc >> 8));
break;
// if in the first half-period, then high
if ( (phase_acc & 0x8000) == 0 ) {
} else {
}
break;
// in first half-period, then
if ( (phase_acc & 0x8000) == 0 ) {
// else, in the second half of period
} else {
}
break;
temp1 = phase_acc - 32768;
break;
temp1 = (phase_acc << 1) - 32768;
temp1 = -(phase_acc << 1) + 32767;
temp1 = 32767;
temp1 = -32768;
rails are +32767, -32768
// pointer to the lookup table
// holds the result of a 16-bit multiply
// clear T4 overflow flag
// increment phase accumulator
y = mx + b
Rev. 1.1

Related parts for AN123