完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
ADC DMA多通道 进行采样时,获取到得数据与实际不一致,单通道时是对的
void MX_ADC1_Init(void) { ADC_ChannelConfTypeDef sConfig = {0}; /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) */ hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; hadc1.Init.Resolution = ADC_RESOLUTION_12B; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; hadc1.Init.LowPowerAutoPowerOff = DISABLE; hadc1.Init.ContinuousConvMode = ENABLE; hadc1.Init.NbrOfConversion = 12; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc1.Init.DMAContinuousRequests = ENABLE; hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; hadc1.Init.SamplingTimeCommon1 = ADC_SAMPLETIME_39CYCLES_5; hadc1.Init.SamplingTimeCommon2 = ADC_SAMPLETIME_39CYCLES_5; hadc1.Init.OversamplingMode = DISABLE; hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH; if (HAL_ADC_Init( hadc1) != HAL_OK) { Error_Handler(); } /** Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_0; sConfig.Rank = 0; sConfig.SamplingTime = ADC_SAMPLETIME_39CYCLES_5; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_1; sConfig.Rank = 1; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_2; sConfig.Rank = 2; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_3; sConfig.Rank = 3; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_4; sConfig.Rank = 4; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_5; sConfig.Rank = 5; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_6; sConfig.Rank = 6; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_7; sConfig.Rank = 7; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_8; sConfig.Rank = 8; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_9; sConfig.Rank = 9; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_10; sConfig.Rank = 10; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } sConfig.Channel = ADC_CHANNEL_11; sConfig.Rank = 11; if (HAL_ADC_ConfigChannel( hadc1, sConfig) != HAL_OK) { Error_Handler(); } } void adc_Dma_start(void) { HAL_ADCEx_Calibration_Start( hadc1); HAL_ADC_Start_DMA( hadc1,(uint32_t *) adcBuff,12); } |
|
相关推荐
1个回答
|
|
关于G0系列的ADC,你要注意下有两种采集序列的选择问题,如果你选择了 Sequencer set of fully configurable, 此时最多支持8个通道,而且这8个通道还只能在CH0~CH14间选择。如果你希望转换的通道超过8个,请选择 not fully configurable模式。
|
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1641 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1562 浏览 1 评论
990 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
691 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1610 浏览 2 评论
1869浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
655浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
525浏览 3评论
541浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
514浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 14:55 , Processed in 0.956629 second(s), Total 82, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号