Other Parts Discussed in Thread: CC2640, CC2640R2F
chip:cc2640 Pin 4*4
SDK: ble_cc26xx_2_01_01_44627
External hardware structure: ADC sampling by resistor divider
Phenomenon: IO8 is sampled and there is no problem with the sampled value; the code is related to only the IO port is changed to IO9, the sampled value is abnormally small;
Code:
void mmcAdc_doConversion()
{
uint32_t refSource = AUXADC_REF_VDDA_REL;
int32_t gain = 0;
int32_t offset = 0;
int i;
float adcValue30k = 0;
// Enable clock for ADC digital and analog interface (not currently enabled in driver)
AUXWUCClockEnable(AUX_WUC_SOC_CLOCK|AUX_WUC_ADI_CLOCK|AUX_WUC_ADC_CLOCK);
// Disallow STANDBY mode while using the ADC.
Power_setConstraint(Power_SB_DISALLOW);
// Connect AUX IO4 (DIO8) as analog input
AUXADCSelectInput(ADC_COMPB_IN_AUXIO3);
// Set up ADC
AUXADCEnableSync(refSource, AUXADC_SAMPLE_TIME_85P3_US, AUXADC_TRIGGER_MANUAL);
// get adc adjustment gain & offset
gain = AUXADCGetAdjustmentGain(refSource);
offset = AUXADCGetAdjustmentOffset(refSource);
Task_sleep(10);
for ( i = 0; i < CONVERSION_CNT; i ++)
{
AUXADCGenManualTrigger();
while (AUXADCGetFifoStatus() == AUXADC_FIFO_EMPTY_M){}
adcValue30k += AUXADCReadFifo();
}
adcValue30k = adcValue30k / CONVERSION_CNT;
adcValue30k = AUXADCAdjustValueForGainAndOffset(adcValue30k, gain, offset);
adc_0715 = adcValue30k;
}