volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Set load cap for 32k xtal
// LFXT1 startup delay、
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while (IFG1 & OFIFG); // OSCFault flag still set?
// Basic Timer
BTCTL = BT_ADLY_1000; // 1s BT Interrupt
IE2 |= BTIE; // Enable BT interrupt
while(Value!=0)
{
ge=Value%10;
*pLCD++ = char_gen[ge];
Value = Value/10;
}
}
void Disp_BCD_X(unsigned long Value)
{
char *pLCD = (char *)&LCDM1;
int i;
for (i = 0; i < 6; i++) // Process 7 digits
{
*pLCD++ = char_gen[Value & 0x0f]; // Segments to LCD
Value >>= 4; // Process next digit
}
}
//******************************角度计算********************************//
#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer(void)
{
unsigned int x,y;
double angle_f;
unsigned long angle;
unsigned long temp;
int temp_x,temp_y,temp_xe,temp_ye;
double Axis_x,Axis_y;
double result;
Init_QMC5883();
while(1)
{
Read_NByte_Randomaddress(inbuffer,6,0x03);
// Read_NByte_Randomaddress(inbuffer,6,0x00);
// Read_1Byte_Randomaddress(inbuffer,1,0x12);
x=(inbuffer[1]<<8)|inbuffer[0];//Combine MSB and LSB of X Data output register
y=(inbuffer[5]<<8)|inbuffer[4]; //Combine MSB and LSB of Y Data output register