Changeset 22 for trunk/fw_g473rct/Core/Src/adc.c
- Timestamp:
- Aug 29, 2025, 6:15:42 PM (24 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/Core/Src/adc.c
r20 r22 59 59 hadc1.Init.GainCompensation = 0; 60 60 hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; 61 hadc1.Init.EOCSelection = ADC_EOC_S EQ_CONV;61 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 62 62 hadc1.Init.LowPowerAutoWait = DISABLE; 63 63 hadc1.Init.ContinuousConvMode = ENABLE; … … 68 68 hadc1.Init.DMAContinuousRequests = ENABLE; 69 69 hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; 70 hadc1.Init.OversamplingMode = DISABLE; 70 hadc1.Init.OversamplingMode = ENABLE; 71 hadc1.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_256; 72 hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4; 73 hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER; 74 hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE; 71 75 if (HAL_ADC_Init(&hadc1) != HAL_OK) 72 76 { … … 88 92 sConfig.Channel = ADC_CHANNEL_1; 89 93 sConfig.Rank = ADC_REGULAR_RANK_1; 90 sConfig.SamplingTime = ADC_SAMPLETIME_ 2CYCLES_5;94 sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5; 91 95 sConfig.SingleDiff = ADC_DIFFERENTIAL_ENDED; 92 96 sConfig.OffsetNumber = ADC_OFFSET_NONE; … … 123 127 hadc2.Init.GainCompensation = 0; 124 128 hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE; 125 hadc2.Init.EOCSelection = ADC_EOC_S EQ_CONV;129 hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 126 130 hadc2.Init.LowPowerAutoWait = DISABLE; 127 131 hadc2.Init.ContinuousConvMode = ENABLE; … … 130 134 hadc2.Init.DMAContinuousRequests = ENABLE; 131 135 hadc2.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; 132 hadc2.Init.OversamplingMode = DISABLE; 136 hadc2.Init.OversamplingMode = ENABLE; 137 hadc2.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_256; 138 hadc2.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4; 139 hadc2.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER; 140 hadc2.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE; 133 141 if (HAL_ADC_Init(&hadc2) != HAL_OK) 134 142 { … … 140 148 sConfig.Channel = ADC_CHANNEL_3; 141 149 sConfig.Rank = ADC_REGULAR_RANK_1; 142 sConfig.SamplingTime = ADC_SAMPLETIME_ 2CYCLES_5;143 sConfig.SingleDiff = ADC_ DIFFERENTIAL_ENDED;150 sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5; 151 sConfig.SingleDiff = ADC_SINGLE_ENDED; 144 152 sConfig.OffsetNumber = ADC_OFFSET_NONE; 145 153 sConfig.Offset = 0; … … 396 404 hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; 397 405 hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; 398 hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_ HALFWORD;406 hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; 399 407 hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; 400 408 hdma_adc1.Init.Mode = DMA_CIRCULAR; … … 435 443 /**ADC2 GPIO Configuration 436 444 PA6 ------> ADC2_IN3 437 PA7 ------> ADC2_IN4 438 */ 439 GPIO_InitStruct.Pin = ADC2_IN3_UBAT__Pin|ADC2_IN4_UBAT__Pin; 445 */ 446 GPIO_InitStruct.Pin = ADC2_IN3_UBAT__Pin; 440 447 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 441 448 GPIO_InitStruct.Pull = GPIO_NOPULL; 442 HAL_GPIO_Init( GPIOA, &GPIO_InitStruct);449 HAL_GPIO_Init(ADC2_IN3_UBAT__GPIO_Port, &GPIO_InitStruct); 443 450 444 451 /* ADC2 DMA Init */ … … 449 456 hdma_adc2.Init.PeriphInc = DMA_PINC_DISABLE; 450 457 hdma_adc2.Init.MemInc = DMA_MINC_ENABLE; 451 hdma_adc2.Init.PeriphDataAlignment = DMA_PDATAALIGN_ HALFWORD;458 hdma_adc2.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; 452 459 hdma_adc2.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; 453 460 hdma_adc2.Init.Mode = DMA_CIRCULAR; … … 665 672 /**ADC2 GPIO Configuration 666 673 PA6 ------> ADC2_IN3 667 PA7 ------> ADC2_IN4 668 */ 669 HAL_GPIO_DeInit(GPIOA, ADC2_IN3_UBAT__Pin|ADC2_IN4_UBAT__Pin); 674 */ 675 HAL_GPIO_DeInit(ADC2_IN3_UBAT__GPIO_Port, ADC2_IN3_UBAT__Pin); 670 676 671 677 /* ADC2 DMA DeInit */
Note: See TracChangeset
for help on using the changeset viewer.