请问F460的官方例程不可以直接测量引脚电压吗,在例程里面无论怎么改输入通道,测量出来的电压值都是3.3v左右,请问那我要是想测量一个引脚的电压的话应该怎么弄啊,用的例程是adc_sa_base;
static void AdcChannelConfig(void)
{
stc_adc_ch_cfg_t stcChCfg;
uint8_t au8Adc1SaSampTime[ADC1_SA_CHANNEL_COUNT] = ADC1_SA_CHANNEL_SAMPLE_TIME;
uint8_t au8Adc2SaSampTime[ADC2_SA_CHANNEL_COUNT] = ADC2_SA_CHANNEL_SAMPLE_TIME;
MEM_ZERO_STRUCT(stcChCfg);
stcChCfg.u32Channel = ADC1_SA_CHANNEL; //设置采样通道
stcChCfg.u8Sequence = ADC_SEQ_A; //序列A采样
stcChCfg.pu8SampTime = au8Adc1SaSampTime; //ADC通道采样时间
/* 1. Set the ADC pin to analog mode. */
AdcSetChannelPinMode(M4_ADC1, ADC1_CHANNEL, Pin_Mode_Ana);//设置采样引脚模式及通道映射
/* 2. Add ADC channel. */
ADC_AddAdcChannel(M4_ADC1, &stcChCfg);//配置ADC通道设置
/* 3. Configure the average channel if you need. */
ADC_ConfigAvg(M4_ADC1, AdcAvcnt_32);
/* 4. Add average channel if you need. */
ADC_AddAvgChannel(M4_ADC1, ADC1_AVG_CHANNEL);
stcChCfg.u32Channel = ADC2_SA_CHANNEL;
stcChCfg.pu8SampTime = au8Adc2SaSampTime;
/* 1. Set the ADC pin to analog mode. */
AdcSetChannelPinMode(M4_ADC2, ADC2_CHANNEL, Pin_Mode_Ana);
/* 2. Add ADC channel. */
ADC_AddAdcChannel(M4_ADC2, &stcChCfg);
/* 3. Configure the average channel if you need. */
ADC_ConfigAvg(M4_ADC2, AdcAvcnt_64);
/* 4. Add average channel if you need. */
ADC_AddAvgChannel(M4_ADC2, ADC2_AVG_CHANNEL);
}
程序里直接修改设置采样通道这里,加了几个通道,但是每个通道显示的电压还是3.3左右,但是引脚并没有外接电压
|