void Set_DACs(void)
{
sta
tic unsigned phase_acc = 0; // Holds phase accumulator
int SIN_temp, COS_temp; // Temporary 16-bit variables
unsigned char index; // Index into SINE table
phase_acc += PHASE_ADD; // Increment phase accumulator
index = phase_acc >> 8;
这个表达式是什么意思啊?
SIN_temp = SINE_TABLE[index]; // Read the table value
index += 64; // 90 degree phase shift
这个怎么实现的啊?
COS_temp = SINE_TABLE[index];
// Add a DC bias to change the the rails from a bipolar (-32768 to 32767)
// to unipolar (0 to 65535)
// Note: the XOR with 0x8000 translates the bipolar quantity into
// a unipolar quantity.
IDA0 = SIN_temp ^ 0x8000; // Update DAC values
IDA1 = COS_temp ^ 0x8000;
}
index += 64; 递加64,从注释看是实现90度相移,结合 COS_temp = SINE_TABLE[index],应该是1/4周期对应64个点,从当前点往后数64就是1/4周期对应的点
不知道对不对???
一周热门 更多>