cancel
Showing results for 
Search instead for 
Did you mean: 

How should I use argument "Channel" in function: HAL_SDADC_InjectedGetValue(SDADC_HandleTypeDef *hsdadc, uint32_t* Channel)

DMårt
Lead

Hi!

I'm trying to make 16-bit ADC measurement works but I have some trouble understanding the argument Channel.

First I have these SD-ADC channels.

0693W000006EzhIQAS.png0693W000006GXNdQAO.pngSDADC1 have:

  • IN4 = Single zero reference
  • IN6 = Differential
  • IN8 = Differential

SDADC3 have:

  • IN6 = Single zero reference
  • IN8 = Differential

I have study this example and do the same thing as the example does:

https://github.com/STMicroelectronics/STM32CubeF3/blob/8fa3aadf0255818f0ca72ba6a5a6731ef8c585fb/Projects/STM32373C_EVAL/Examples/SDADC/SDADC_Voltmeter/Src/main.c

Yes, it works. But I have 5 measurements, not 1 measurement as the example shows.

I have created a call-back function for the NVIC interrupts for the SDADC's.

But still, I cannot get a stable value, because I'm indexing in wrong channel. Do you know how to do this?

Should I start with

CHANNEL = 0;

Or what should I do?

uint32_t CHANNEL
void HAL_SDADC_InjectedConvCpltCallback(SDADC_HandleTypeDef *hsdadc){
	if(hsdadc->Instance == SDADC1){
		// SD ADC 1
		if(CHANNEL == 4)
			SD_ADC_VALUES[0] = HAL_SDADC_InjectedGetValue(hsdadc, &CHANNEL);
		else if(CHANNEL == 8)
			D_SD_ADC_VALUES[0] = HAL_SDADC_InjectedGetValue(hsdadc, &CHANNEL);
		else if(CHANNEL == 6)
			D_SD_ADC_VALUES[1] = HAL_SDADC_InjectedGetValue(hsdadc, &CHANNEL);
	}else if(hsdadc->Instance == SDADC3){
		if(CHANNEL == 6)
			SD_ADC_VALUES[1] = HAL_SDADC_InjectedGetValue(hsdadc, &CHANNEL);
		else if(CHANNEL == 8)
			D_SD_ADC_VALUES[2] = HAL_SDADC_InjectedGetValue(hsdadc, &CHANNEL);
	}
}

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-Computer
0 REPLIES 0