请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:EVM430-FR6043 您好
在 文件 USSLibGUIApp.c 中的演示项目 MSP430FR6043EVM_USS_Demo 中。我想查看我捕获的向上/向下流动值:
pUPSCap = USS_getUPSPtr (&gUssSWConfig);
pDNSCap = USS_getDNSPtr (&gUssSWConfig);
我还需要发送固定流速:
PrepareVolumeFlowVarForI2CFixed(algResFixed.iq16VolumeFlowRate);
请在无限 while 循环中向我展示、其中是放置这些命令的最佳位置:
/* Start Flow Measurement -- Main loop */
while(1)
{
P1OUT ^= BIT5; //blink LED
// HMI function called before measurement to check for new packets
// or perform user interaction (LCD/buttons) before measurement
HMI_PreMeasurement_Update();
if (HMI_STATUS_FATAL_ERROR != HMI_GetStatus())
{
#ifdef __ENABLE_LPM__
// Perform a low power measurement, going to LPM3 in between UPS and DNS
code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
#else
// Perform a regular measurement, staying in LPM0 during capture
code = USS_startUltrasonicMeasurement(&gUssSWConfig,
USS_capture_power_mode_low_power_mode_0);
#endif
// Invalid capture must report error
if (USS_message_code_no_error != code)
{
if (USSSWLIB_USS_interrupt_status & USS_HSPLL_PLL_UNLOCK_INTERRUPT)
{
USS_resetUSSModule(&gUssSWConfig, true);
USSLibGUIApp_send_error(COMMAND_HANDLER_ERROR_FAULT_INVALID_CAPTURE,
(uint16_t) USS_message_code_HSPLL_pll_unlock_error);
}
else
{
USSLibGUIApp_send_error(COMMAND_HANDLER_ERROR_FAULT_INVALID_CAPTURE,
(uint16_t) code);
}
}
else // run algorithms on the captured results
{
#ifdef USS_APP_DC_OFFSET_CANCELLATION_ENABLE
// Calibrate the gain amplifier.
// This routine will update the agcConstant with optimal gain
if (USS_App_userConfig.u16DCOffsetEstimateInterval != 0)
{
if (++dcOffsetEstcount >= USS_App_userConfig.u16DCOffsetEstimateInterval)
{
dcOffsetEstcount = 0;
// Perform DC offset estimation using measurement sequence going
// to LPM3 between UPS and DNS capture
code = USS_estimateDCoffset(&gUssSWConfig,
USS_dcOffEst_Calc_Mode_use_existing_UPS_DNS_capture );
}
}
#endif
// HMI function called after measurement and before algorithms
// are executed.
// Used to send ADC waveforms before manipulation
HMI_PostMeasurement_Update();
code = USS_runAlgorithmsFixedPoint(&gUssSWConfig,&algResFixed);
if ( (USS_message_code_valid_results != code) &&
(USS_message_code_algorithm_captures_accumulated != code) )
{
//Invalid algorithm results, report error
USSLibGUIApp_send_error(COMMAND_HANDLER_ERROR_FAULT_ALG_ERROR,
(uint16_t) code);
}
}
}
#ifdef USS_APP_RESONATOR_CALIBRATE_ENABLE
// Calibrate the Resonator against the LFXT and obtain the correction
// term relative to the expected value obtained during the
// Initialization
if (++resCalibcount >= USS_App_userConfig.u16ResonatorCalibrateInterval)
{
resCalibcount = 0;
code = USS_verifyHSPLLFrequency(&gUssSWConfig,&pllCalibTestResults);
if (code == USS_message_code_no_error)
{
// Update relative error if the HSPLL frequency is within range
gUssSWConfig.algorithmsConfig->clockRelativeError =
(_IQ27div(pllCalibTestResults.difference,
pllCalibTestResults.expectedResult));
USS_updateClockRelativeError(&gUssSWConfig);
}
else
{
// Report error if the HSPLL frequency is outside the expected range
if (code == USS_message_code_HSPLL_pll_unlock_error)
{
// Reset USS if a PLL unlock errror is detected
USS_resetUSSModule(&gUssSWConfig, true);
}
USSLibGUIApp_send_error(COMMAND_HANDLER_ERROR_FAULT_INVALID_CAPTURE,
code);
}
}
#endif
#ifdef USS_APP_AGC_CALIBRATE_ENABLE
// Calibrate the gain amplifier.
// This routine will update the agcConstant with optimal gain.
if (USS_App_userConfig.u16AGCCalibrateInterval != 0)
{
if (++agcCalibcount >= USS_App_userConfig.u16AGCCalibrateInterval)
{
agcCalibcount = 0;
code = USS_calibrateSignalGain(&gUssSWConfig);
}
}
#endif
#ifdef __WATCHDOG_ENABLE__
hal_system_WatchdogFeed();
#endif
// HMI function called after algorithms are executed
// Used to send results of algorithms.
HMI_PostAlgorithm_Update(&algResFixed);
pUPSCap = USS_getUPSPtr(&gUssSWConfig);
pDNSCap = USS_getDNSPtr(&gUssSWConfig);
// prepareVolumeFlowVarForI2C(algResults.volumeFlowRate);
prepareVolumeFlowVarForI2CFixed(algResFixed.iq16VolumeFlowRate);
USSLibGUIApp_Delay(); /* Delay for proper time */
}
目前、我已在延迟前的末尾放置了
谢谢。
