- PC1, ADC1 IN11
- PC2 ADC1 IN12
- PA6 ADC2 IN6
- PA7 ADC2 IN7
- PB0 ADC2 IN8
- Temp Sensor ADC1
- VrefInt ADC1
- Vbatt ADC1
using System;
using System.Diagnostics;
using System.Threading;
using System.Device.Adc;
namespace ADCMeasure
{
public class Program
{
private static int adcValue;
public static void Main()
{
AdcController adcController = new AdcController();
AdcChannel pa6Channel = adcController.OpenChannel(6);
while (true)
{
adcValue = pa6Channel.ReadValue();
double ratio = pa6Channel.ReadRatio();
Debug.WriteLine($"{nameof(adcValue)}: {adcValue}; {nameof(ratio)}: {ratio}; MaxValue: {adcController.MaxValue}; MinValue: {adcController.MinValue}");
Thread.Sleep( 1000 );
}
}
}
}
adcValue: 1695; ratio: 0.41343101; MaxValue: 4095; MinValue: 0
adcValue: 4; ratio: 0; MaxValue: 4095; MinValue: 0
#include <sys_dev_adc_native_target.h>
const NF_PAL_ADC_PORT_PIN_CHANNEL AdcPortPinConfig[] = {
// ADC1
{1, GPIOC, 1, ADC_CHANNEL_IN11},
{1, GPIOC, 2, ADC_CHANNEL_IN12},
// ADC2
{2, GPIOA, 6, ADC_CHANNEL_IN6},
{2, GPIOA, 7, ADC_CHANNEL_IN7},
{2, GPIOB, 0, ADC_CHANNEL_IN8},
// these are the internal sources, available only at ADC1
{1, NULL, 0, ADC_CHANNEL_SENSOR},
{1, NULL, 0, ADC_CHANNEL_VREFINT},
{1, NULL, 0, ADC_CHANNEL_VBAT},
};
const int AdcChannelCount = ARRAYSIZE(AdcPortPinConfig);