cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger ADC with TIM3 on STM32L452

JWolf.5
Associate

The reference manual states that the STM32L452 should be able to use an TIM3_TRGO as a trigger for ADC conversion:

0693W00000SvAYOQA3.pngThough when I try to setup the "External Trigger Conversion Source" in STM32CubeMX there is no drop-down option for Timer 3, only TIM1/TIM2/TIM6/TIM15:

0693W00000SvAZ2QAN.pngAm I doing something wrong? Can I just ignore the STM32CubeMX and insert the appropriate EXTSEL-bits in the code myself?

1 ACCEPTED SOLUTION

Accepted Solutions
Semer CHERNI
ST Employee

Hello @JWolf.5​ 

First let me thank you for having reported :smiling_face_with_smiling_eyes:

Actually you're right, I've been able to reproduce the same misbehavior from my side when using the same configuration as you.

As you mentioned in your poste you can set the EXTSEL-bits in the code as a temporary solution while we investigate the issue.

I want to add an other solution; you can use the already declared macro to set TIM3_TRGO.

In the static void MX_ADC1_Init(void) function change make the modification showed bellow:

  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
  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.ContinuousConvMode = DISABLE;
  hadc1.Init.NbrOfConversion = 1;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T3_TRGO; // change ADC_EXTERNALTRIG_T1_TRGO with ADC_EXTERNALTRIG_T3_TRGO
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
  hadc1.Init.DMAContinuousRequests = DISABLE;
  hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  hadc1.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    Error_Handler();
  }

  

With this being said, this problem is raised internally to be reviewed. I'll keep you posted with the updates.

Internal ticket number: 134734 (This is an internal tracking number and is not accessible or usable by customers).

Thanks for your contribution.

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Semer CHERNI
ST Employee

Hello @JWolf.5​ 

First let me thank you for having reported :smiling_face_with_smiling_eyes:

Actually you're right, I've been able to reproduce the same misbehavior from my side when using the same configuration as you.

As you mentioned in your poste you can set the EXTSEL-bits in the code as a temporary solution while we investigate the issue.

I want to add an other solution; you can use the already declared macro to set TIM3_TRGO.

In the static void MX_ADC1_Init(void) function change make the modification showed bellow:

  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
  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.ContinuousConvMode = DISABLE;
  hadc1.Init.NbrOfConversion = 1;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T3_TRGO; // change ADC_EXTERNALTRIG_T1_TRGO with ADC_EXTERNALTRIG_T3_TRGO
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
  hadc1.Init.DMAContinuousRequests = DISABLE;
  hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  hadc1.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    Error_Handler();
  }

  

With this being said, this problem is raised internally to be reviewed. I'll keep you posted with the updates.

Internal ticket number: 134734 (This is an internal tracking number and is not accessible or usable by customers).

Thanks for your contribution.

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.