利用MAXQ7667確定超聲傳感器的諧振頻率和阻尼特性
half_peak = STIM; // save the time it took to reach half the peak value.
i = 101; // Half peak found so exit the loop.
}
while (T2CNB0_bit.TF2 == 0) {} // Wait for timer # 0.
T2CNB0_bit.TF2 = 0; // Clear flag.
}
T2CNA0_bit.TR2 = 0; // Stop timer # 0.
return half_peak;
}
void main()
{
unsigned short i = 0;
unsigned short peak = 0;
unsigned short first70 = 0;
unsigned short second70 = 0;
unsigned short center_pllf;
unsigned short wait2measure;
unsigned short halfpeak;
init();
// **********************************
// **********************************
// Configuration settings
echo_receive_gain(0); // Set receiver to minimum gain (allowed values 0-31)
Burst_Clock_Divider = 400; // for calculating the burst-frequency in PC-Application.
burst_setup(BURST_CLK_PLL, BURST_PULSE_1, BURST_DIV_400, 0, PLL_CLOCK_16MHZ, 0);
step_size=10; // Sets the step-size (steps go from 0 to 511).
// END configuration settings.
// ******************************
// ******************************
while(1)
評論