bremenpl

adc

Apr 6th, 2016
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. /* ADC2 init function */
  2. void MX_ADC2_Init(void)
  3. {
  4.   ADC_ChannelConfTypeDef sConfig;
  5.  
  6.     /**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
  7.     */
  8.   hadc2.Instance = ADC2;
  9.   hadc2.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4;
  10.   hadc2.Init.Resolution = ADC_RESOLUTION12b;
  11.   hadc2.Init.ScanConvMode = ENABLE;
  12.   hadc2.Init.ContinuousConvMode = ENABLE;
  13.   hadc2.Init.DiscontinuousConvMode = DISABLE;
  14.   hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING;
  15.   hadc2.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T8_TRGO;
  16.   hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  17.   hadc2.Init.NbrOfConversion = 2;
  18.   hadc2.Init.DMAContinuousRequests = ENABLE;
  19.   hadc2.Init.EOCSelection = EOC_SEQ_CONV;
  20.   HAL_ADC_Init(&hadc2);
  21.  
  22.     /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
  23.     */
  24.   sConfig.Channel = ADC_CHANNEL_14;
  25.   sConfig.Rank = 1;
  26.   sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
  27.   HAL_ADC_ConfigChannel(&hadc2, &sConfig);
  28.  
  29.     /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
  30.     */
  31.   sConfig.Channel = ADC_CHANNEL_15;
  32.   sConfig.Rank = 2;
  33.   HAL_ADC_ConfigChannel(&hadc2, &sConfig);
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment