//ch: 通道值 0~16,取值范围为:ADC_CHANNEL_0~ADC_CHANNEL_16 //返回值:转换结果 unsigned short Get_Adc(ADC_HandleTypeDef *ADC_Handler,unsigned int ch) { ADC_ChannelConfTypeDef sConfig = {0}; sConfig.Channel = ADC_CHANNEL_3; sConfig.Rank = ADC_REGULAR_RANK_1; sConfig.SamplingTime = A...
先对ADC1基于DMA标准请求模式做演示。 随意选择ADC1的4个通道,扫描模式,连续转换,DMA传输转换结果并令DMA工作在外设字到内存字的循环传输模式。使用CubeMx进行配置。其中DMA通道使用Channel 1。 相关代码: #defineADC_BUFFRER_SIZE((uint32_t)8)uint32_tADC1_Result[ADC_BUFFRER_SIZE];ADC_HandleTypeDefhadc1;D...
ADC1_Cmd(ENABLE); ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_3, ADC1_PRESSEL_FCPU_D18, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL3,DISABLE); ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_4, ADC1_PRESSEL_FCPU_D18, ADC1_EXTTRIG_TIM...
ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 4, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 5, ADC_SampleT...
ADC_RegularChannelConfig(ADC2, ADC_Channel_4, 1, ADC_SampleTime_239Cycles5); //通道配置 /* ...
/* Configure ADC Channel11 as analog input */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 ;GPIO_...
2.如果通道设置不连续,比如channel 6 4 3 那么DMA传输的数就不正常,数据寄存器后面的几个数是错误的; 3.设置的首地址,比如源程序里是 ADC1->RES_OUT7.reg,这个通道即使没有勾选,这个通道也是采集了的,而且会把数据放在数据寄存器数组的第一位,adc_ch_result[0]; ...
as sampling time */ ADC_ChannelConfig(ADC1, ADC_Channel_4 , ADC_SampleTime_1_5Cycles);...
ADC1->CR1 |= (ADC1_CR1_SPSEL & (0x02<<4)); //fADC = 4 MHz ADC1->CR2 |= ADC1...
1.在上一章的工程基础上我们增加TIM1 channel 4的触发源,作为ADC电流采样注入组的触发源;分别修改ADC1和ADC2的注入组转换触发源为TIM1比较4事件; 2.首先将PB1配置增加COMP1_INP功能; 3.设置DAC_CHI连接MCU内部外设,其他参数默认,不需要修改; 4.设置COMP1的INP及INM,配置上升沿触发中断; ...