locate.h

来自「利用AD976采一个陀螺仪的数据」· C头文件 代码 · 共 37 行

H
37
字号
#define Vdd 5.0
#define MAX 100
#include "AD976.h"

extern float theta;
extern float w;

float VSG_Input[100];
float Avrg;
int index;

void Init_TimerA()
{
  TACCTL0 |= CCIE;
  CCR0 = 6000;
  TACTL |= TASSEL_2+TACLR+MC_1;
}

#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A(void)
{
  VSG_Input[index] = Cvt_AD976();
  index++;
  index = index%MAX;
  if(index==MAX-1)
  {
    float SUM=0;
    for(int i=0;i<MAX;i++)
    {
      SUM=SUM+VSG_Input[i];
    }
    Avrg=(float)SUM/(float)MAX;
    w=(Avrg-2.482)*400.0/Vdd;
    theta += w;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?