• ADC配置变量

    //*****************************************************************************
    //
    // ADC Configuration
    //
    //*****************************************************************************
    const static am_hal_adc_config_t g_sADC_Cfg =
    {//// Select the ADC Clock source.//.eClock = AM_HAL_ADC_CLKSEL_HFRC_DIV2,//// Polarity//.ePolarity = AM_HAL_ADC_TRIGPOL_RISING,//// Select the ADC trigger source using a trigger source macro.//.eTrigger = AM_HAL_ADC_TRIGSEL_SOFTWARE,//// Select the ADC reference voltage.//.eReference = AM_HAL_ADC_REFSEL_INT_1P5,.eClockMode = AM_HAL_ADC_CLKMODE_LOW_POWER,//// Choose the power mode for the ADC's idle state.//.ePowerMode = AM_HAL_ADC_LPMODE1,//// Enable repeating samples using Timer3A.//.eRepeat = AM_HAL_ADC_REPEATING_SCAN
    };

eClock ADC时钟源选择

//
// ADC clock selection.
//
typedef enum
{AM_HAL_ADC_CLKSEL_OFF,AM_HAL_ADC_CLKSEL_HFRC,AM_HAL_ADC_CLKSEL_HFRC_DIV2
} am_hal_adc_clksel_e;

ePolarity ADC触发极性选择

//
// ADC trigger polarity
//
typedef enum
{AM_HAL_ADC_TRIGPOL_RISING,AM_HAL_ADC_TRIGPOL_FALLING
} am_hal_adc_trigpol_e;

eTrigger ADC触发源选择

//
// ADC trigger selection
//
typedef enum
{AM_HAL_ADC_TRIGSEL_EXT0,AM_HAL_ADC_TRIGSEL_EXT1,AM_HAL_ADC_TRIGSEL_EXT2,AM_HAL_ADC_TRIGSEL_EXT3,AM_HAL_ADC_TRIGSEL_VCOMP,AM_HAL_ADC_TRIGSEL_SOFTWARE = 7
} am_hal_adc_trigsel_e;

eReference ADC参考电压选择

//
// ADC reference selection.
//
typedef enum
{AM_HAL_ADC_REFSEL_INT_2P0,AM_HAL_ADC_REFSEL_INT_1P5,AM_HAL_ADC_REFSEL_EXT_2P0,AM_HAL_ADC_REFSEL_EXT_1P5
} am_hal_adc_refsel_e;

eClockMode ADC时钟模式选择


// ADC clock mode selection.
//
typedef enum
{AM_HAL_ADC_CLKMODE_LOW_POWER,   // Disable the clock between scans for LPMODE0.// Set LPCKMODE to 0x1 while configuring the ADC.AM_HAL_ADC_CLKMODE_LOW_LATENCY  // Low Latency Clock Mode. When set, HFRC and the// adc_clk will remain on while in functioning in LPMODE0.
} am_hal_adc_clkmode_e;

ePowerMode ADC低功耗模工选择


// ADC low-power mode selection.
//
typedef enum
{AM_HAL_ADC_LPMODE0,  // Low Latency Clock Mode. When set, HFRC and the adc_clk// will remain on while in functioning in LPMODE0.AM_HAL_ADC_LPMODE1   // Powers down all circuity and clocks associated with the// ADC until the next trigger event. Between scans, the reference// buffer requires up to 50us of delay from a scan trigger event// before the conversion will commence while operating in this mode.
} am_hal_adc_lpmode_e;

eRepeat ADC周期采样与单次采样选择

//
// ADC repetition selection.
//
typedef enum
{AM_HAL_ADC_SINGLE_SCAN,AM_HAL_ADC_REPEATING_SCAN
} am_hal_adc_repeat_e;
  • Timer配置

am_hal_ctimer_config_t g_sTimer3 =
{// do not link A and B together to make a long 32-bit counter..ui32Link = 0,// Set up timer 3A to drive the ADC.ui32TimerAConfig = (AM_HAL_CTIMER_FN_PWM_REPEAT |AM_HAL_CTIMER_LFRC_32HZ),// Timer 3B is not used in this example..ui32TimerBConfig =0,
};

ui32Link Timer连接配置

Set to 1 to operate this timer as a 32-bit timer instead of two 16-bit timers.

ui32TimerAConfig TimerA配置

Configuration options for TIMERA

ui32TimerBConfig TimerB配置

Configuration options for TIMERB

初时化ADC功能

uint32_t am_hal_adc_initialize(uint32_t ui32Module, void **ppHandle)

  1. 参数ui32Module只能为0,超出会初时化失败
  2. 参数void **ppHandle指向一个处理句柄指针的指针

ADC电源配置

uint32_t am_hal_adc_power_control(void *pHandle,am_hal_sysctrl_power_state_e ePowerState,bool bRetainState)

  1. 参数void *pHandle为处理句柄指针
  2. 参数am_hal_sysctrl_power_state_e ePowerState为电源状态
//
// Definition of Global Power State enumeration
//
//*****************************************************************************
typedef enum
{AM_HAL_SYSCTRL_WAKE,AM_HAL_SYSCTRL_NORMALSLEEP,AM_HAL_SYSCTRL_DEEPSLEEP
} am_hal_sysctrl_power_state_e;

3.    参数bool bRetainState为是否开启保存及恢复状态值

flag (if true) to save/restore peripheral state upon power state change.

ADC配置

uint32_t am_hal_adc_configure(void *pHandle, am_hal_adc_config_t *psConfig)

  1. 参数void *pHandle为处理句柄指针
  2. 参数am_hal_adc_config_t *psConfig为指向ADC配置信息的指针

ADC slot配置

uint32_t am_hal_adc_configure_slot(void *pHandle, uint32_t ui32SlotNumber,am_hal_adc_slot_config_t *pSlotConfig)

  1. 参数void *pHandle为处理句柄指针
  2. 参数uint32_t ui32SlotNumber为ADC slot,取值为0~7
  3. 参数am_hal_adc_slot_config_t *pSlotConfig指向ADC slot配置
//*****************************************************************************
//
//! @brief Configuration structure for the ADC slot.
//
//*****************************************************************************
typedef struct
{//! Select the number of measurements to averageam_hal_adc_meas_avg_e         eMeasToAvg;//! Select the precision modeam_hal_adc_slot_prec_e        ePrecisionMode;//! Select the channelam_hal_adc_slot_chan_e        eChannel;//! Select window comparison modebool                          bWindowCompare;//! Enable the slotbool                          bEnabled;} am_hal_adc_slot_config_t;

使能ADC功能

uint32_t am_hal_adc_enable(void *pHandle)

参数void *pHandle为处理句柄指针

timer时钟产生控制

uint32_t am_hal_clkgen_control(am_hal_clkgen_control_e eControl, void *pArgs)

  1. 参数am_hal_clkgen_control_e eControl为时钟控制
//
// Control operations.
//
typedef enum
{AM_HAL_CLKGEN_CONTROL_SYSCLK_MAX,AM_HAL_CLKGEN_CONTROL_XTAL_START,AM_HAL_CLKGEN_CONTROL_LFRC_START,AM_HAL_CLKGEN_CONTROL_XTAL_STOP,AM_HAL_CLKGEN_CONTROL_LFRC_STOP,AM_HAL_CLKGEN_CONTROL_SYSCLK_DIV2,AM_HAL_CLKGEN_CONTROL_RTC_SEL_XTAL,AM_HAL_CLKGEN_CONTROL_RTC_SEL_LFRC,AM_HAL_CLKGEN_CONTROL_HFADJ_ENABLE,AM_HAL_CLKGEN_CONTROL_HFADJ_DISABLE,
} am_hal_clkgen_control_e;

2.  参数void *pArgs指向时钟调整控制参数,如果为NULL则使用默认的值

清除Timer标志

void am_hal_ctimer_clear(uint32_t ui32TimerNumber, uint32_t ui32TimerSegment)

  1. 参数uint32_t ui32TimerNumber定时器序号,从里取3
  2. 参数uint32_t ui32TimerSegment定时器段
#define AM_HAL_CTIMER_TIMERA                0x0000FFFF
#define AM_HAL_CTIMER_TIMERB                0xFFFF0000
#define AM_HAL_CTIMER_BOTH                  0xFFFFFFFF

定时器配置

void am_hal_ctimer_config(uint32_t ui32TimerNumber,am_hal_ctimer_config_t *psConfig)

  1. 参数uint32_t ui32TimerNumber为定时器序号,这里取3
  2. 参数am_hal_ctimer_config_t *psConfig指向定时器配置信息

配置定时器周期

void am_hal_ctimer_period_set(uint32_t ui32TimerNumber, uint32_t ui32TimerSegment,uint32_t ui32Period, uint32_t ui32OnTime)

  1. 参数(uint32_t ui32TimerNumber为定时器序号,这里取3
  2. 参数uint32_t ui32TimerSegment为定时器段
#define AM_HAL_CTIMER_TIMERA                0x0000FFFF
#define AM_HAL_CTIMER_TIMERB                0xFFFF0000
#define AM_HAL_CTIMER_BOTH                  0xFFFFFFFF

3.    参数uint32_t ui32Period为定时器周期

4. 参数uint32_t ui32OnTime:set the number of clocks where the output signal is high

使能timer触发ADC

void am_hal_ctimer_adc_trigger_enable(void)

启动定时器

void am_hal_ctimer_start(uint32_t ui32TimerNumber, uint32_t ui32TimerSegment)

  1. 参数uint32_t ui32TimerNumber为定时器序号,这里取3
  2. 参数uint32_t ui32TimerSegment为定时器段
#define AM_HAL_CTIMER_TIMERA                0x0000FFFF
#define AM_HAL_CTIMER_TIMERB                0xFFFF0000
#define AM_HAL_CTIMER_BOTH                  0xFFFFFFFF
  • 以测量VBATT和TEMP为例

//*****************************************************************************
//
//! @file hello_world.c
//!
//! @brief A simple "Hello World" example.
//!
//! Purpose: This example prints a "Hello World" message with some device info.
//!
//! Printing takes place over the ITM at 1M Baud.
//!
//
//*****************************************************************************//*****************************************************************************
//
// Copyright (c) 2019, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision v2.3.1-167-ge65d79147 of the AmbiqSuite Development Package.
//
//*****************************************************************************#include "am_mcu_apollo.h"
#include "am_bsp.h"
#include "am_util.h"const static am_hal_adc_config_t g_sADC_Cfg =
{.eClock = AM_HAL_ADC_CLKSEL_HFRC_DIV2,.ePolarity = AM_HAL_ADC_TRIGPOL_RISING,.eTrigger = AM_HAL_ADC_TRIGSEL_SOFTWARE,.eReference = AM_HAL_ADC_REFSEL_INT_1P5,.eClockMode = AM_HAL_ADC_CLKMODE_LOW_POWER,.ePowerMode = AM_HAL_ADC_LPMODE1,.eRepeat = AM_HAL_ADC_REPEATING_SCAN
};am_hal_ctimer_config_t g_sTimer3 =
{.ui32Link = 0,.ui32TimerAConfig = (AM_HAL_CTIMER_FN_PWM_REPEAT | AM_HAL_CTIMER_LFRC_32HZ),.ui32TimerBConfig = 0};static void *g_ADCHandle;
uint16_t g_ui16ADCTEMP_code;
uint32_t g_ui32SampleCount;
uint16_t g_ui16ADCVDD_code;void adc_init(void)
{am_hal_adc_slot_config_t sSlotCfg;//// Initialize the ADC and get the handle.//if ( AM_HAL_STATUS_SUCCESS != am_hal_adc_initialize(0, &g_ADCHandle) ){am_util_stdio_printf("Error - reservation of the ADC instance failed.\n");}//// Power on the ADC.//if (AM_HAL_STATUS_SUCCESS != am_hal_adc_power_control(g_ADCHandle,AM_HAL_SYSCTRL_WAKE,false) ){am_util_stdio_printf("Error - ADC power on failed.\n");}//// Configure the ADC.//if ( am_hal_adc_configure(g_ADCHandle, (am_hal_adc_config_t*)&g_sADC_Cfg) != AM_HAL_STATUS_SUCCESS ){am_util_stdio_printf("Error - configuring ADC failed.\n");}sSlotCfg.bEnabled       = false;sSlotCfg.bWindowCompare = false;sSlotCfg.eChannel       = AM_HAL_ADC_SLOT_CHSEL_SE0;    // 0sSlotCfg.eMeasToAvg     = AM_HAL_ADC_SLOT_AVG_1;        // 0sSlotCfg.ePrecisionMode = AM_HAL_ADC_SLOT_14BIT;        // 0am_hal_adc_configure_slot(g_ADCHandle, 0, &sSlotCfg);   // Unused slotam_hal_adc_configure_slot(g_ADCHandle, 1, &sSlotCfg);   // Unused slotam_hal_adc_configure_slot(g_ADCHandle, 2, &sSlotCfg);   // Unused slotam_hal_adc_configure_slot(g_ADCHandle, 3, &sSlotCfg);   // Unused slotam_hal_adc_configure_slot(g_ADCHandle, 4, &sSlotCfg);   // Unused slotam_hal_adc_configure_slot(g_ADCHandle, 6, &sSlotCfg);   // Unused slotsSlotCfg.bEnabled       = true;sSlotCfg.bWindowCompare = true;sSlotCfg.eChannel       = AM_HAL_ADC_SLOT_CHSEL_BATT;sSlotCfg.eMeasToAvg     = AM_HAL_ADC_SLOT_AVG_1;sSlotCfg.ePrecisionMode = AM_HAL_ADC_SLOT_14BIT;am_hal_adc_configure_slot(g_ADCHandle, 5, &sSlotCfg);   // BATTsSlotCfg.bEnabled       = true;sSlotCfg.bWindowCompare = true;sSlotCfg.eChannel       = AM_HAL_ADC_SLOT_CHSEL_TEMP;sSlotCfg.eMeasToAvg     = AM_HAL_ADC_SLOT_AVG_1;sSlotCfg.ePrecisionMode = AM_HAL_ADC_SLOT_10BIT;am_hal_adc_configure_slot(g_ADCHandle, 7, &sSlotCfg);   // TEMP//// Enable the ADC.//am_hal_adc_enable(g_ADCHandle);
}static void timer_init(void)
{
//
// Only CTIMER 3 supports the ADC.
//
#define TIMERNUM    3uint32_t ui32Period = 2000; // Set for 2 second (2000ms) period//// LFRC has to be turned on for this example because we are running this// timer off of the LFRC.//am_hal_clkgen_control(AM_HAL_CLKGEN_CONTROL_LFRC_START, 0);//// Set up timer 3A so start by clearing it.//am_hal_ctimer_clear(TIMERNUM, AM_HAL_CTIMER_TIMERA);//// Configure the timer to count 32Hz LFRC clocks but don't start it yet.//am_hal_ctimer_config(TIMERNUM, &g_sTimer3);//// Compute CMPR value needed for desired period based on a 32HZ clock.//ui32Period = ui32Period * 32 / 1000;am_hal_ctimer_period_set(TIMERNUM, AM_HAL_CTIMER_TIMERA,ui32Period, (ui32Period >> 1));//// Set up timer 3A as the trigger source for the ADC.//am_hal_ctimer_adc_trigger_enable();//// Start timer 3A.//am_hal_ctimer_start(TIMERNUM, AM_HAL_CTIMER_TIMERA);
} // time//
// ADC code for voltage divider from ADC ISR to base level.
//void am_adc_isr(void)
{uint32_t ui32IntStatus;//// Clear timer 3 interrupt.//am_hal_adc_interrupt_status(g_ADCHandle, &ui32IntStatus, true);am_hal_adc_interrupt_clear(g_ADCHandle, ui32IntStatus);//// Toggle LED 3.//float fADCTempVolts;float fADCTempDegreesC;float fTrims[4];uint32_t ui32NumSamples = 1;am_hal_adc_sample_t sSample;//// Go get the sample.////// Emtpy the FIFO, we'll just look at the last one read.am_util_stdio_printf("FIFO COUNT=%d\n",AM_HAL_ADC_FIFO_COUNT(ADC->FIFO));while ( AM_HAL_ADC_FIFO_COUNT(ADC->FIFO) ){ui32NumSamples = 1;am_hal_adc_samples_read(g_ADCHandle, true, NULL, &ui32NumSamples, &sSample);//// Determine which slot it came from?//if (sSample.ui32Slot == 5 ){//// The returned ADC sample is for the battery voltage divider.//g_ui16ADCVDD_code = AM_HAL_ADC_FIFO_SAMPLE(sSample.ui32Sample);}else{//// The returned ADC sample is for the temperature sensor.// We need the integer part in the low 16-bits.//g_ui16ADCTEMP_code = sSample.ui32Sample & 0xFFC0;}}//// Signal interrupt arrival to base level.//g_ui32SampleCount++;
}//*****************************************************************************
//
// Main
//
//*****************************************************************************
int main(void)
{am_util_id_t sIdDevice;uint32_t ui32StrBuf;//// Set the clock frequency.//am_hal_clkgen_control(AM_HAL_CLKGEN_CONTROL_SYSCLK_MAX, 0);//// Set the default cache configuration//am_hal_cachectrl_config(&am_hal_cachectrl_defaults);am_hal_cachectrl_enable();//// Configure the board for low power operation.//am_bsp_low_power_init();//// Initialize the printf interface for ITM output//am_bsp_itm_printf_enable();//// Print the banner.//am_util_stdio_terminal_clear();am_util_stdio_printf("Hello World!\n\n");//// Print the device info.//am_util_id_device(&sIdDevice);am_util_stdio_printf("Vendor Name: %s\n", sIdDevice.pui8VendorName);am_util_stdio_printf("Device type: %s\n", sIdDevice.pui8DeviceName);am_util_stdio_printf("Qualified: %s\n",sIdDevice.sMcuCtrlDevice.ui32Qualified ?"Yes" : "No");am_util_stdio_printf("Device Info:\n""\tPart number: 0x%08X\n""\tChip ID0:    0x%08X\n""\tChip ID1:    0x%08X\n""\tRevision:    0x%08X (Rev%c%c)\n",sIdDevice.sMcuCtrlDevice.ui32ChipPN,sIdDevice.sMcuCtrlDevice.ui32ChipID0,sIdDevice.sMcuCtrlDevice.ui32ChipID1,sIdDevice.sMcuCtrlDevice.ui32ChipRev,sIdDevice.ui8ChipRevMaj, sIdDevice.ui8ChipRevMin );//// If not a multiple of 1024 bytes, append a plus sign to the KB.//ui32StrBuf = ( sIdDevice.sMcuCtrlDevice.ui32FlashSize % 1024 ) ? '+' : 0;am_util_stdio_printf("\tFlash size:  %7d (%d KB%s)\n",sIdDevice.sMcuCtrlDevice.ui32FlashSize,sIdDevice.sMcuCtrlDevice.ui32FlashSize / 1024,&ui32StrBuf);ui32StrBuf = ( sIdDevice.sMcuCtrlDevice.ui32SRAMSize % 1024 ) ? '+' : 0;am_util_stdio_printf("\tSRAM size:   %7d (%d KB%s)\n\n",sIdDevice.sMcuCtrlDevice.ui32SRAMSize,sIdDevice.sMcuCtrlDevice.ui32SRAMSize / 1024,&ui32StrBuf);//// Print the compiler version.//am_util_stdio_printf("App Compiler:    %s\n", COMPILER_VERSION);
#if defined(AM_PART_APOLLO3)  || defined(AM_PART_APOLLO3P)am_util_stdio_printf("HAL Compiler:    %s\n", g_ui8HALcompiler);am_util_stdio_printf("HAL SDK version: %d.%d.%d\n",g_ui32HALversion.s.Major,g_ui32HALversion.s.Minor,g_ui32HALversion.s.Revision);am_util_stdio_printf("HAL compiled with %s-style registers\n",g_ui32HALversion.s.bAMREGS ? "AM_REG" : "CMSIS");am_hal_security_info_t secInfo;char sINFO[32];uint32_t ui32Status;ui32Status = am_hal_security_get_info(&secInfo);if (ui32Status == AM_HAL_STATUS_SUCCESS){if ( secInfo.bInfo0Valid ){am_util_stdio_sprintf(sINFO, "INFO0 valid, ver 0x%X", secInfo.info0Version);}else{am_util_stdio_sprintf(sINFO, "INFO0 invalid");}am_util_stdio_printf("SBL ver: 0x%x - 0x%x, %s\n",secInfo.sblVersion, secInfo.sblVersionAddInfo, sINFO);}else{am_util_stdio_printf("am_hal_security_get_info failed 0x%X\n", ui32Status);}
#endif // AM_PART_APOLLO3//// We are done printing.// Disable debug printf messages on ITM.//
//    am_bsp_debug_printf_disable();am_hal_sysctrl_fpu_enable();am_hal_sysctrl_fpu_stacking_enable(true);//// Initialize the ADC.//adc_init();//// Initialize CTIMER 3A to trigger the ADC every 0.5 seconds.//timer_init();NVIC_EnableIRQ(ADC_IRQn);am_hal_interrupt_master_enable();//// Enable the ADC interrupts in the ADC.//am_hal_adc_interrupt_enable(g_ADCHandle, AM_HAL_ADC_INT_WCINC       |AM_HAL_ADC_INT_WCEXC       |AM_HAL_ADC_INT_FIFOOVR2    |AM_HAL_ADC_INT_FIFOOVR1    |AM_HAL_ADC_INT_SCNCMP      |AM_HAL_ADC_INT_CNVCMP);//// Reset the sample count which will be incremented by the ISR.//g_ui32SampleCount = 0;//// Kick Start Timer 3 with an ADC software trigger in REPEAT used.//am_hal_adc_sw_trigger(g_ADCHandle);//// Track buffer depth for progress messages.//int32_t i32BaseLevelCount = g_ui32SampleCount;const float fReferenceVoltage = 1.5;float fVBATT;uint32_t ui32Retval;float fADCTempVolts;float fADCTempDegreesC;float fTrims[4];float fTempF;//// Loop forever while sleeping.//while (1){if (g_ui32SampleCount > i32BaseLevelCount){i32BaseLevelCount = g_ui32SampleCount;//// Compute the voltage divider output.//fVBATT = ((float)g_ui16ADCVDD_code) * 3.0f * fReferenceVoltage / (1024.0f / 64.0f);//// Print the voltage divider output.//am_util_stdio_printf("VBATT = <%.3f> (0x%04X) ",fVBATT, g_ui16ADCVDD_code);//// Convert and scale the temperature.// Temperatures are in Fahrenheit range -40 to 225 degrees.// Voltage range is 0.825V to 1.283V// First get the ADC voltage corresponding to temperature.//fADCTempVolts = ((float)g_ui16ADCTEMP_code) * fReferenceVoltage / (1024.0f * 64.0f);//// Now call the HAL routine to convert volts to degrees Celsius.//float fVT[3];fVT[0] = fADCTempVolts;fVT[1] = 0.0f;fVT[2] = -123.456;
//          fADCTempDegreesC = am_hal_adc_volts_to_celsius(fADCTempVolts);ui32Retval = am_hal_adc_control(g_ADCHandle, AM_HAL_ADC_REQ_TEMP_CELSIUS_GET, fVT);if ( ui32Retval == AM_HAL_STATUS_SUCCESS ){fADCTempDegreesC = fVT[1];  // Get the temperature//// print the temperature value in Celsius.//am_util_stdio_printf("TEMP = %.2f C (0x%04X) ",fADCTempDegreesC, g_ui16ADCTEMP_code);//// Print the temperature value in Fahrenheit.//fTempF = (fADCTempDegreesC * (180.0f / 100.0f)) + 32.0f;am_util_stdio_printf(" %.2f F", fTempF);}else{am_util_stdio_printf("Error: am_haL_adc_control returned %d\n", ui32Retval);}//// Use button 0 to turn on or off the battery load resistor.//am_util_stdio_printf("\n");} //// Go to Deep Sleep.//am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_DEEP);}
}

Apollo 3 plus ADC for Timer3A sample相关推荐

  1. 【RT-Thread】nxp rt10xx 设备驱动框架之--adc搭建和使用

    ADC(Analog-to-Digital Converter) 指模数转换器.将模拟电压信号转换成数字信号,通常ADC接口会连接一些传感器,如:温度传感器:陀螺仪加速度计:电位器等等. 开发前准备 ...

  2. STM32F0 ADC学习

    开始时候使用的是stdlib的库,最近发现cube库用的越来越广泛了,遂开始使用cube库来完成ADC的多通道采集实验. ADC 的driver 在STM32F0XX_HAL_DRIVER当中,有st ...

  3. IWR6843ISK捕获并分析原始ADC数据

    文章目录 原始数据介绍 参考代码 matlab读取数据参考代码 python读取数据参考代码 我这里使用的设备为 IWR6843ISK+DCA1000EVM+mmWave Studio 参考资料:采用 ...

  4. ADC采集实现温度检测

    1 使用nordic库实现 nRF52832ADC采集的一个例子 https://www.cnblogs.com/zzu-liulei/p/6519141.html 2 用nRF52840自带的ADC ...

  5. RTT添加AD驱动代码

    1.在Kconfig文件中添加如下内容 menuconfig BSP_USING_ADC         bool "Enable ADC"         default n   ...

  6. TI AWR1642毫米波雷达学习笔记之理论基础(2)

    背景:在知道毫米波雷达信号数学模型后,我们开始对TSW1400开发板采集的原始数据进行处理.本文主要讲解信号处理时涉及的1D FFT和2D FFT处理时前期数据处理,主要为将数据格式处理为天线维-快时 ...

  7. Xiaojie雷达之路---TI实战笔记---对AWR1843+DCA1000采集的数据进行解析

    这篇文章主要是介绍对AWR1843和DCA1000采集的数据进行解析 下面两张图要必须看懂,才能进行以后的操作: 图1: 这张图片主要说明的意思是对于每个tx的chirp,每个rx都会接收到 从上面这 ...

  8. TMS320F280049C 学习笔记17 可编程增益放大器 Programmable Gain Amplifier (PGA)

    文章目录 概述 与其他模拟子系统的配合 示例 PGA DAC-ADC External Loopback Example 参考文献 概述 可编程增益放大器(PGA)用于放大输入电压以增加后级ADC和C ...

  9. 雷达实测数据处理流程

    前言:最近在进行雷达实测数据的处理,是按块学的,包括:波形参数设置.ADC数据读取.2D-FFT处理.CFAR检测目标.测距测速测角,比较散,这篇笔记将前后处理串起来,形成一个体系. 一.波形参数设置 ...

最新文章

  1. Kotlin中使用简洁明了的代码替换findViewByid
  2. redis常用命令getex_Redis常用命令(key、string、List)
  3. 利用规划图提高经典人工智能规划复杂度
  4. oracle中简单查询语句的格式及执行顺序分析
  5. javaheapspace解决方案_高手总结的9种 OOM 常见原因及解决方案
  6. [Windowns C]递归遍历指定目录下的子目录和文件
  7. LeetCode 1716. 计算力扣银行的钱(等差数列)
  8. 杭电oj 1000 c++ 版本
  9. 《ArcGIS Runtime SDK for Android开发笔记》——问题集:如何解决ArcGIS Runtime SDK for Android中文标注无法显示的问题(转载)...
  10. linux通过数字权限设置密码,linux--权限管理和用户管理
  11. Android——selector背景选择器的使用详解(二)
  12. Java生成bmp图片_利用24位BMP图实现信息隐写(java语言)
  13. ERD Commander 2005 使用教程
  14. 无法打开FTP在 windows资源管理器中打开FTP站点解决方法
  15. YYC松鼠短视频系统v3.5版本--稳定版本---优化性能以及各处接口返回以及部分ui页面细节
  16. Python 三维姿态估计+Unity3d 实现 3D 虚拟现实交互游戏
  17. mysql 公历变农历_经过完整测试的农历-公历相互转换
  18. ERROR 2000 (HY000): Unknown MySQL error
  19. 日更100天(33)每天进步一点点
  20. 现实迷途 第二十八章 钱珊其人

热门文章

  1. 分享给好友功能的实现
  2. 20款惊艳的矢量花纹素材
  3. 漫步数理统计二十七——t与F分布
  4. 逆战d3dx10_43.dll文件加载失败及dll文件缺失损坏修复解决方案
  5. 2018宝妈创业项目有哪些?宝妈怎么创业?
  6. AD9361 FIR 滤波器设计
  7. 64位计算机不能运行32位游戏,我想玩个游戏,仅支援64位系统,我家电脑win7 32位的,怎么办求解决方法...
  8. Unity游戏开发之排行榜(采用PlayerPrefs存储)
  9. 子组件获取外层组件的scrollTop,达到实时定位的效果
  10. AutoCAD二次开发的好处