Skip to main content
Associate II
November 14, 2024
Solved

Missing case for ADC2 software start in STM32f7xx HAL driver HAL_Adc_Start_IT()

  • November 14, 2024
  • 1 reply
  • 751 views

Hi,

 

Looks like the HAL driver for the STM32f7xx ADC is missing a case for using the software start of the ADC2 peripheral in the HAL_ADC_Start_IT function.

 

Starting from line 1128:

 else
 {
 /* if instance of handle correspond to ADC1 and no external trigger present enable software conversion of regular channels */
 if((hadc->Instance == ADC1) && ((hadc->Instance->CR2 & ADC_CR2_EXTEN) == RESET))
 {
 /* Enable the selected ADC software conversion for regular group */
 hadc->Instance->CR2 |= (uint32_t)ADC_CR2_SWSTART;
 }

 /* if dual mode is selected, ADC3 works independently. */
 /* check if the mode selected is not triple */
 if( HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI_4) )
 {
 /* if instance of handle correspond to ADC3 and no external trigger present enable software conversion of regular channels */
 if((hadc->Instance == ADC3) && ((hadc->Instance->CR2 & ADC_CR2_EXTEN) == RESET))
 {
 /* Enable the selected ADC software conversion for regular group */
 hadc->Instance->CR2 |= (uint32_t)ADC_CR2_SWSTART;
 }
 } 

 

I think ADC2 should also be considered in this function. In fact, it is not mentioned anywhere in this driver...

Best answer by mƎALLEm

Hello,

It's considered at this line:

SofLit_0-1731597027918.png

Condition: No ADC multimode configured.

Knowing that in multimode ADC1 is the master.

1 reply

mƎALLEm
mƎALLEmBest answer
Technical Moderator
November 14, 2024

Hello,

It's considered at this line:

SofLit_0-1731597027918.png

Condition: No ADC multimode configured.

Knowing that in multimode ADC1 is the master.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
nick_bergAuthor
Associate II
November 14, 2024

You are right, I accidentally enabled the multi mode by writing too large a value to CCR->ADCPRE...

Thanks