完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
|
|
没有用过,只能帮楼主加人气了。
|
|
|
|
|
|
|
|
网上有教程的
|
|
|
|
STM32F373的SDADC编写过多通道数据采集
ADC_InitStructure.ADC_ScanConvMode = ENABLE;//扫描方式,这个一定要打开 ADC_RegularChannelConfig(ADC1, ADC_Channel_0 , 1, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_239Cycles5); 设置好采集顺序,dma会先发送先采集的通道的数据,后发送后采集的通道的数据 |
|
|
|
太新。。。没用过。。。
|
|
|
|
/* SDADC1 init function */
void MX_SDADC1_Init(void) { SDADC_ConfParamTypeDef ConfParamStruct = {0}; /** Configure the SDADC low power mode, fast conversion mode, slow clock mode and SDADC1 reference voltage */ hsdadc1.Instance = SDADC1; hsdadc1.Init.IdleLowPowerMode = SDADC_LOWPOWER_NONE; hsdadc1.Init.FastConversionMode = SDADC_FAST_CONV_ENABLE; hsdadc1.Init.SlowClockMode = SDADC_SLOW_CLOCK_DISABLE; hsdadc1.Init.ReferenceVoltage = SDADC_VREF_EXT; if (HAL_SDADC_Init(&hsdadc1) != HAL_OK) { Error_Handler(); } /** Set parameters for SDADC configuration 0 Register */ ConfParamStruct.InputMode = SDADC_INPUT_MODE_SE_OFFSET; ConfParamStruct.Gain = SDADC_GAIN_1; ConfParamStruct.CommonMode = SDADC_COMMON_MODE_VSSA; ConfParamStruct.Offset = 0; if (HAL_SDADC_PrepareChannelConfig(&hsdadc1, SDADC_CONF_INDEX_0, &ConfParamStruct) != HAL_OK) { Error_Handler(); } /** Configure the Regular Channel */ if (HAL_SDADC_AssociateChannelConfig(&hsdadc1, SDADC_CHANNEL_4 + SDADC_CHANNEL_5 + SDADC_CHANNEL_6, SDADC_CONF_INDEX_0) != HAL_OK) { Error_Handler(); } /** Calibrate the SDADC in configuration 0 */ HAL_SDADC_CalibrationStart(&hsdadc1, SDADC_CALIBRATION_SEQ_1); if (HAL_SDADC_PollForCalibEvent(&hsdadc1, 50) != HAL_OK){ Error_Handler(); } /** Configure The Regular Mode */ if (HAL_SDADC_SelectRegularTrigger(&hsdadc1, SDADC_SOFTWARE_TRIGGER) != HAL_OK) { Error_Handler(); } if (HAL_SDADC_ConfigChannel(&hsdadc1, SDADC_CHANNEL_4, SDADC_CONTINUOUS_CONV_ON) != HAL_OK) { Error_Handler(); } } void HAL_SDADC_MspInit(SDADC_HandleTypeDef* sdadcHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(sdadcHandle->Instance==SDADC1) { /* USER CODE BEGIN SDADC1_MspInit 0 */ /* USER CODE END SDADC1_MspInit 0 */ /* SDADC1 clock enable */ __HAL_RCC_SDADC1_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**SDADC1 GPIO Configuration PB0 ------> SDADC1_AIN6P PB1 ------> SDADC1_AIN5P PB2 ------> SDADC1_AIN4P */ GPIO_InitStruct.Pin = Temperature_Pin|BGVoltage_Pin|BGCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* SDADC1 DMA Init */ /* SDADC1 Init */ hdma_sdadc1.Instance = DMA2_Channel3; hdma_sdadc1.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_sdadc1.Init.PeriphInc = DMA_PINC_DISABLE; hdma_sdadc1.Init.MemInc = DMA_MINC_ENABLE; hdma_sdadc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; hdma_sdadc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; hdma_sdadc1.Init.Mode = DMA_NORMAL; hdma_sdadc1.Init.Priority = DMA_PRIORITY_HIGH; if (HAL_DMA_Init(&hdma_sdadc1) != HAL_OK) { Error_Handler(); } __HAL_LINKDMA(sdadcHandle,hdma,hdma_sdadc1); /* USER CODE BEGIN SDADC1_MspInit 1 */ /* USER CODE END SDADC1_MspInit 1 */ } } void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; /** Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_ADC1 |RCC_PERIPHCLK_SDADC; PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; PeriphClkInit.SdadcClockSelection = RCC_SDADCSYSCLK_DIV12; PeriphClkInit.Adc1ClockSelection = RCC_ADC1PCLK2_DIV2; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } HAL_PWREx_EnableSDADC(PWR_SDADC_ANALOG1); /** Enables the Clock Security System */ HAL_RCC_EnableCSS(); } |
|
|
|
楼主现在会配置了嘛
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
STM32串口接受中断使用C++STL中的queue导致所有中断失效
3038 浏览 1 评论
2666 浏览 0 评论
STM32配合可编程加密芯片SMEC88ST的防抄板加密方案设计
1279 浏览 0 评论
3528 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
3327 浏览 4 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-31 22:40 , Processed in 0.559002 second(s), Total 56, Slave 50 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号