cancel
Showing results for 
Search instead for 
Did you mean: 

2 ADC channels assigned to 1 MCU pin

DavidNaviaux
Senior

I have designed a buck converter that uses the MCU to regulate its output voltage.

I am using one pin for the voltage feedback that will be used to regulate the output.  However, because it has to read this pin very quickly, the sample period has been set to 2.5 clock cycles and thus the effective resolution is not very good (fine for control though).  I see that I can assign multiple ADC channels to a single pin.

If I assign two ADC channels to the same pin, can I use one of the ADCs to read the voltage on the pin with much more precision at the same time the alternate ADC is being used to regulate the voltage without effecting control?

 

5 REPLIES 5
Pierre_Paris
ST Employee

Hello @DavidNaviaux,

Here are some guidance for your application :

  • First, which pin are you currently using ? Please check on the table 12 pin definition of the DS12288 (for STM32G474) and select a pin (PC0 for ADC_IN6 or PC1 for ADC12_IN7)
  • Indeed, the sample period effect the resolution. Are you aware of the AN3116 named ADC modes and their applications (see Dual interleaved mode) ? 
  • To avoid effecting control and loss of data, I recommend to use DMA to offload the CPU.

Best Regards,

Pierre

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.

Pierre,

I am using PB15 (ADC4_IN5) with a fixed negative offset to give me an error signal for the FMAC.  It appears that I can have multiple ADC channels assigned to that pin, i.e. PB15 looks like I can assign ADC4_IN5 and ADC2_IN15.  Currently I am using DMA to transfer the ADC4_IN5 results to the FMAC to be processed.

If I can assign multiple ADC inputs to a pin and I add ADC2_IN15 to PB15 (i.e., both ADC2_IN15 and ADC4_IN5 are highlighted), can I use ADC2 to read a more precise voltage on that pin without effecting the ADC4_IN5 results transferred by DMA to the FMAC (ADC_IN5 is being sampled every 5us)?

Thanks,

David

 

Pierre_Paris
ST Employee

@DavidNaviaux,

Here are some remark/answers:

  • ADC4 and ADC2 cannot operate in dual mode (only ADC1 with ADC2 and ADC3 with ADC4)
  • Can I use ADC2 to read a more precise voltage on that pin without effecting the ADC4_IN5 results transferred by DMA to the FMAC (ADC_IN5 is being sampled every 5us)? -> The analog signal will enter both in ADC2_IN15 and ADC4_IN5 (check figure 85 & 87 of RM0440) so yes you can. If I understood, you want to choose an other sampling for ADC2, that's it ? If you want a higher sampling rate, the best option stay dual interleaved mode. ADC1 and ADC2 convert the same channel alternately to reduce the conversion time. While ADC1 samples channel CHx, ADC2 converts the previous sample.
  • For the resolution, configure it to the maximum : 12 bits (by programming the control bits RES[1:0]. Lower resolution allows faster conversion time for applications where high-data precision is not required.

Best Regards,

Pierre

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.

Pierre,

Thank you for your quick responses (I have to finish the firmware within a week!).

What I was concerned about is if a pin is being converted by two ADC converters that are not synchronized in any way, will the source impedance of the analog signal to the pin (1k ohm in my case) affect either of the conversions if they happen to be converting at the same time?

In my application, I am not concerned about the speed of the sampling of ADC2_IN15 since it will only be used to provide accurate feedback to an operator.  However, the timing of ADC4_IN5 is critical since it is used as feedback for regulating the output voltage of the buck converter with a PWM frequency of 200kHz (i.e., sampled every 5us).

Thanks again,

David

 

 

Pierre_Paris
ST Employee

Hello @DavidNaviaux,

Q : What I was concerned about is if a pin is being converted by two ADC converters that are not synchronized in any way, will the source impedance of the analog signal to the pin (1k ohm in my case) affect either of the conversions if they happen to be converting at the same time?

A :  No, it's not possible to use ADC2 and ADC4 with a single pin at the same time without any synchronization. The risk is the noise between them if they sample at the same time. Below, when the switch closes, noise is generated which can be detected by the second ADC.

Pierre_P_0-1701426229676.png

 

 

 

Best Regards,

Pierre

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.