adc配置: void MY_ADC_Init(void) { ADC_ChannelConfTypeDef ADC1_ChanConf; ADC1_Handler.Instance = ADC1; ADC1_Handler.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; ADC1_Handler.Init.Resolution = ADC_RESOLUTION_12B; ADC1_Handler.Init.DataAlign = ADC_DATAALIGN_RIGHT; ADC1_Handler.Init.ScanConvMode = ADC_SCAN_ENABLE; ADC1_Handler.Init.EOCSelection = DISABLE; ADC1_Handler.Init.ContinuousConvMode = ENABLE; ADC1_Handler.Init.DiscontinuousConvMode = DISABLE; ADC1_Handler.Init.NbrOfConversion = 2; ADC1_Handler.Init.NbrOfDiscConversion = 0; ADC1_Handler.Init.ExternalTrigConv = ADC_SOFTWARE_START; ADC1_Handler.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; ADC1_Handler.Init.LowPowerAutoWait = DISABLE; ADC1_Handler.Init.DMAContinuousRequests = ENABLE; ADC1_Handler.Init.Overrun = ADC_OVR_DATA_PRESERVED; ADC1_Handler.Init.OversamplingMode = DISABLE; ADC1_ChanConf.Channel = ADC_CHANNEL_1; ADC1_ChanConf.Rank = ADC_REGULAR_RANK_1; ADC1_ChanConf.SamplingTime = ADC_SAMPLETIME_47CYCLES_5; ADC1_ChanConf.SingleDiff = ADC_SINGLE_ENDED; ADC1_ChanConf.OffsetNumber = ADC_OFFSET_NONE; ADC1_ChanConf.Offset = 0; HAL_ADC_ConfigChannel(&ADC1_Handler, &ADC1_ChanConf); ADC1_ChanConf.Channel = ADC_CHANNEL_2; ADC1_ChanConf.Rank = ADC_REGULAR_RANK_2; ADC1_ChanConf.SamplingTime = ADC_SAMPLETIME_47CYCLES_5; ADC1_ChanConf.SingleDiff = ADC_SINGLE_ENDED; ADC1_ChanConf.OffsetNumber = ADC_OFFSET_NONE; ADC1_ChanConf.Offset = 0; ADC1_Handler.Init.DMAContinuousRequests = ENABLE; HAL_ADC_Init(&ADC1_Handler); HAL_ADC_Start(&ADC1_Handler); } DMA配置 void MYDMA_Config(DMA_Channel_TypeDef *DMA_Channel, u32 seq)// { __HAL_RCC_DMA1_CLK_ENABLE(); ADC1DMA_Handler.Instance = DMA1_Channel1; ADC1DMA_Handler.Init.Request = seq; ADC1DMA_Handler.Init.Direction = DMA_PERIPH_TO_MEMORY; ADC1DMA_Handler.Init.PeriphInc = DMA_PINC_DISABLE; ADC1DMA_Handler.Init.MemInc = DMA_MINC_ENABLE; ADC1DMA_Handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; ADC1DMA_Handler.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; ADC1DMA_Handler.Init.Mode = DMA_CIRCULAR; ADC1DMA_Handler.Init.Priority = DMA_PRIORITY_HIGH; HAL_DMA_Init(&ADC1DMA_Handler); HAL_DMA_DeInit(&ADC1DMA_Handler); __HAL_LINKDMA(&ADC1_Handler, DMA_Handle, ADC1DMA_Handler); } main中调用 HAL_ADC_Start_DMA(&ADC1_Handler, (uint32_t*)&AD_DMA, 2); 但AD_DMA中的数为0,不知道哪里出问题了,求大神帮忙看下 |
问个关于STM32L4 SPI读数据,前3个字节永远是0
STM32L432 2个SPI同时使用的问题
STM32L476 ADC采集内部温度传感器电压值
STM32L431通过串口下载程序问题
ST的hal库有问题手头有STM32L4或STM32F7的帮忙测试DMA SD卡
STM32L476-Discovery开发板如何进行串口固件烧写
大家有用到STM32L433的CAN通信的吗?
STM32L4 FFT 自带arm_math.h编译不成功
想问一个关于STM32L475 flash的问题
谁有STM32L476的编程手册,传一个,感谢
评分
查看全部评分
这句貌似把初始化完成的DMA又关闭了。
评分
查看全部评分
当然需要配置,那些配置没什么问题,就没必要贴出来了
谢谢,是这个问题,已解决
评分
查看全部评分
嗯,已经开始用CubeMX了,确实省事很多,谢谢