5444 views|0 replies

6552

Posts

0

Resources
The OP
 

CC2640R2F ADC [Copy link]

Now I provide an ADC subroutine that I wrote myself, which has been verified by many people and can be used.
The subroutine is as follows:

#include "AppAdc.h"
#include <inc/hw_types.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <inc/hw_memmap.h>
#include <driverlib/aux_wuc.h>
#include <driverlib/aux_adc.h>
#include <inc/hw_aux_evctl.h>
#include <inc/hw_adi.h>
#include <inc/hw_adi_4_aux.h>
#include <inc/hw_aux_anaif.h> // Will change name to anaif
uint32_t AdcOneShotRead(uint8_t auxIo,uint8 reg)
{
uint32_t turnedOnClocks = 0;
//////////// Config clock/////////////////////
// Only turn on clocks that are not already enabled. Not thread-safe, obviously.
turnedOnClocks |= AUXWUCClockStatus(AUX_WUC_ADC_CLOCK) ? 0 : AUX_WUC_ADC_CLOCK;
turnedOnClocks |= AUXWUCClockStatus(AUX_WUC_ADI_CLOCK) ? 0 : AUX_WUC_ADI_CLOCK;
turnedOnClocks |= AUXWUCClockStatus(AUX_WUC_ANAIF_CLOCK) ? 0 : AUX_WUC_ANAIF_CLOCK;
// Enable clocks and wait for ready
AUXWUCClockEnable(turnedOnClocks);
while(AUX_WUC_CLOCK_OFF == AUXWUCClockStatus(turnedOnClocks));
/////// Seclect auxIO /////////////
AUXADCSelectInput(auxIo);
////////// Enable ///////////
AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);
// delay(10);
//Scaling disable
if(reg) AUXADCDisableInputScaling(); //本条没屏蔽,最大的ADC电压为1.49V,适合低电压检测
AUXADCGenManualTrigger(); // Trigger sample
// HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_ADCTRIG) = (1 << AUX_ANAIF_ADCTRIG_START_S);
uint32_t adcValue = AUXADCReadFifo();
AUXADCDisable();//Power_Saving
return adcValue;
}

第一行是自己定义的一个头文件。
函数返回4字节的AD结果。
函数形参auxIo,代表对哪个通道进行采集。

This post is from Wireless Connectivity
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list