|
如题,官方没有定时器触发ADC的例程,我测试的时候发现定时器更新事件不能连续触发ADC,以下是我的配置信息,求大神指点!
void BSTIM_INIT()
{
LL_BSTIM_InitTypeDef INSTRUC;
INSTRUC.Prescaler=80;
INSTRUC.Autoreload=10000;
INSTRUC.AutoreloadState=ENABLE;
INSTRUC.ClockSource=LL_RCC_BSTIM_OPERATION_CLK_SOURCE_APBCLK2;
LL_BSTIM_Init(BSTIM,&INSTRUC);
LL_BSTIM_SetMasterSynSrc(BSTIM,LL_BSTIM_MASTER_SYN_SRC_UE);
LL_BSTIM_EnableCounter(BSTIM);
}
void AdcInit(void)
{
LL_GPIO_InitTypeDef GPIO_InitStruct;
LL_ADC_CommonInitTypeDef ADC_CommonInitStruct;
LL_ADC_InitTypeDef ADC_InitStruct ;
//配置引脚为模拟功能
//ADC ADC_0 引脚 PC9
GPIO_InitStruct.Pin = LL_GPIO_PIN_9;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = DISABLE;
GPIO_InitStruct.RemapPin = DISABLE;
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
//ADC 时钟设置
ADC_CommonInitStruct.AdcClockSource = LL_RCC_ADC_OPERATION_CLOCK_PRESCALLER_RCHF; //RCHF
ADC_CommonInitStruct.AdcClockPrescaler = LL_RCC_ADC_OPERATION_CLOCK_PRESCALER_DIV8; //16分频
LL_ADC_CommonInit(&ADC_CommonInitStruct);
//ADC 寄存器设置
ADC_InitStruct.ADC_ContinuousConvMode = LL_ADC_CONV_SINGLE;//单次模式
ADC_InitStruct.ADC_AutoMode = LL_ADC_SINGLE_CONV_MODE_AUTO;//自动
ADC_InitStruct.ADC_ScanDirection = LL_ADC_SEQ_SCAN_DIR_FORWARD;//通道正序扫描
ADC_InitStruct.ADC_ExternalTrigConv = LL_ADC_EXT_TRIGGER_RISING;//
ADC_InitStruct.ADC_SamplingTrigSource = LL_ADC_TRIG_EXT_BSTIM1_TRGO;//硬件触发源选择
ADC_InitStruct.ADC_OverrunMode = LL_ADC_OVR_DATA_OVERWRITTEN;//覆盖上次数据
ADC_InitStruct.ADC_WaitMode = LL_ADC_WAIT_MODE_WAIT;//等待
ADC_InitStruct.ADC_Channel_Swap_Wait = LL_ADC_SAMPLEING_INTERVAL_11_CYCLES;//通道切换等待时间
ADC_InitStruct.ADC_Channel_Fast_Time = LL_ADC_FAST_CH_SAMPLING_TIME_4_ADCCLK;//快速通道采样时间
ADC_InitStruct.ADC_Channel_Slow_Time = LL_ADC_SLOW_CH_SAMPLING_TIME_192_ADCCLK;//慢速通道采样时间
ADC_InitStruct.ADC_Oversampling = DISABLE;//过采样关闭
ADC_InitStruct.ADC_OverSampingRatio = LL_ADC_OVERSAMPLING_8X;//8倍过采样
ADC_InitStruct.ADC_OversamplingShift = LL_ADC_OVERSAMPLING_RESULT_DIV8;//数据右移, /8
LL_ADC_Init(ADC, &ADC_InitStruct);
LL_RCC_SetADCPrescaler(LL_RCC_ADC_OPERATION_CLOCK_PRESCALER_DIV1);
LL_VREF_EnableVREFBuffer(VREF);//使能VREF BUFFER
LL_ADC_EnalbleSequencerChannel(ADC, LL_ADC_EXTERNAL_CH_0);//通道选择ADC_0
LL_ADC_ClearFlag_EOC(ADC);//清标志
LL_ADC_Enable(ADC); // 启动ADC
//LL_ADC_StartConversion(ADC); // 开始转换
}
|
-
-
|