Showing results for 
Search instead for 
Did you mean: 

Sharing inputs between ADC and Comparators on STM32F303

Associate II

I am new to STM32 and am trying to choose between a 64-pin and 100-pin STM32F303 for a power converter project, the answer to this question determines if I can make it work with only 64 pins - please help.

I need 7 differential ADC inputs (both + and - inputs will be external) and 7 comparator (both + and - inputs will be external). The ADC channels and comparators actually monitor the same 7 differential signals - the comparator outputs simply generate interrupts once the inputs change sign, the ADC polls and measures the differential inputs periodically. The Reference Manual shows that the 7 available comparators have specific input pin assignments in accordance with Table 108 "Comparator input/output summary" on p443. The ADCs of course have much greater flexibility, each with many pin options to choose for differential inputs, although many of them are the same as the ones used for the comparators.

The question is - can the ADC inputs be assigned to the same pins that I use for the comparators? hence 14 inputs (7 differential pairs) between the peripherals, OR, do the comparator and ADC inputs for each pair have to be assigned to different pins and hence I have to route the ADC inputs to different external pins and connect them externally on the PCB to the ones being used for the comparators?

Many thanks for your help.



> same pins


I'd recommend you to do a proof of concept experiment on a cheap Nucleo or Disco board, with the same chip you intend to use. Note, that 'F303 are in fact 3 distinct models, depending on the memories size, with quite some differences when it comes to the comparators.


> I'd recommend you to do a proof of concept experiment

... among other things, users are sometimes surprised when they see the sampling-induced spikes on the ADC inputs waveforms; this might result in surprising output of the attached comparator, to.

Also, mind the surprisingly limited Common-Mode Input Range of ADC, when in differential mode, see DS.


thanks Jan,

just to clarify your answer... you are saying effectively, "yes in principle the ADC and Comp can be connected to the same differential pair, but test it just to be sure"?? (which I intend to do on Nucleo of Mikroe Fusion btw.)




They are connected, there's no problem with that; I was just warning of effects described in the post below.


thanks again Jan, and I forgot to mention, I am using the versions with 7 comparators (e.g. '303xD or '303xE) and memory not an issue for my application.

that info is very useful... if I get erratic Comparator responses when ADC sampling I will just have to disable the Comparator output interrupt. I am fascinated by your point about the common mode range for differential ADC inputs. The DS has this listed in Table 79 on page 134, which unfortunately has an ambiguous spec for this parameter, it says that the ...

CMIR Common Mode Input signal range (ADC differential mode) = min of (VSSA + VREF+)/2 – 0.18V, a typical of course is (VSSA + VREF+)/2, and a corresponding max of (VSSA + VREF+)/2 + 0.18V.

This point of yours is absolutely critical and I am now wondering which of two possible interpretations of the CM spec is correct... taking my example the isolation amplifier output which feeds into the ADC has a CM value of about 1.45V and I was going to set VDDA on the 100pin '303 @ 2.50V using a precision reference and VSSA @ GND, until I saw your point.

Interpretation #1 of the DS is that the CM range is nominally (VSSA + VREF+)/2 with an 0.18V tolerance, i.e it is (0+2.5)/2 = 1.25V for my application ignoring the tolerance, and centred at half the VDDA value , hence ranges from 625mV up to 1875mV, a range of 1.25V - so for a 1.45V CM input I am fine.

Interpretation #2 of the DS is that the CM range is actually only +/-0.18V and centred at VDDA/2, hence would only be between 1.07V and 1.43V for a 2.5V VREF+. This is breaching my nominal 1.45V CM input!

Which of these interpretations do you think is correct? if its #2, then I will abandon the 2.5V reference and set a VREF+ of exactly twice my nominal input CM - i.e 2 x 1.45V = 2.9V.

It would be great to get your view on this and thanks again for pointing it out.



IMO #2

It's somewhat surprising and it was probably not in the DS, as it's in the Errata too.

I don't know the reason and would love to hear a thorough explanation from ST.