微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 谁能帮忙解释一下这段程序~!

谁能帮忙解释一下这段程序~!

时间:10-02 整理:3721RD 点击:
void Set_DACs(void)
{
   static 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 = phase_acc >> 8;                 右移8位,也就是除以2^8
index += 64;    递加64,从注释看是实现90度相移,结合 COS_temp = SINE_TABLE[index],应该是1/4周期对应64个点,从当前点往后数64就是1/4周期对应的点
不知道对不对?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top