//初始化HMC5883,根据需要请参考pdf进行修改****
void Init_HMC5883()
{
Single_Write_HMC5883(0x02,0x00); //
}
//*********************************************************
//主程序********
//*********************************************************
void main()
{ // bit sign_bit;
unsigned int i;
int x,y,z;
double angle;
delay(500);
InitLcd();
Init_HMC5883();
while(1) //循环
{
Multiple_Read_HMC5883(); //连续读出数据,存储在BUF中
//---------显示X轴
x=BUF[0] << 8 | BUF[1]; //Combine MSB and LSB of X Data output register
z=BUF[2] << 8 | BUF[3]; //Combine MSB and LSB of Z Data output register
y=BUF[4] << 8 | BUF[5]; //Combine MSB and LSB of Y Data output register
//初始化HMC5883,根据需要请参考pdf进行修改****
void Init_HMC5883()
{
Single_Write_HMC5883(0x02,0x00); //
}
//*********************************************************
//主程序********
//*********************************************************
void main()
{
// bit sign_bit;
unsigned int i;
int X,Y,Z;
double Angle_XY=0,Angle_XZ=0,Angle_YZ=0;
Delay_ms(500);
InitLcd();
Init_HMC5883();
while(1) //循环
{
Multiple_Read_HMC5883(); //连续读出数据,存储在BUF中
//---------显示X轴
X=BUF[0] << 8 | BUF[1]; //Combine MSB and LSB of X Data output register 最高有效位
Z=BUF[2] << 8 | BUF[3]; //Combine MSB and LSB of Z Data output register
Y=BUF[4] << 8 | BUF[5]; //Combine MSB and LSB of Y Data output register