cancel
Showing results for 
Search instead for 
Did you mean: 

Can overlapping IN\OUT pins be used to internally route peripherals on STM32G4?

KHarb.1
Senior

I’m using CubeIDE and I want to internally connect peripherals to the comparators. This doesn’t appear to be supported by CubeIDE, but I’m wondering if its still supported by hardware somehow.

I’m using an STM32G4 and I see that COMP6 INP lands on PB11, which is the same pin as OPAMP6 OUT. Can a pin overlap like this enable internal routing of OPAMP6 to COMP6?

I can also see that OPAMP outputs can be mapped to ADC inputs that also fall on external pins that overlap with COMP comparator inputs. PA2 doubles as COMP2 OUT and ADC1 IN3, which can map internally to OPAMP2_VOUT. Would this work?

Similarly, I want to drive a USART RX with comparators routed internally. I see that COMP6 OUT can land on the same pin as USART1 RX. Can I make the COMP drive the USART like this?

1 ACCEPTED SOLUTION

Accepted Solutions

more interesting question is about comparator and UART... and i bet it is possible too ... 

I just tried, on F303 :

AScha3_0-1716902404973.png

Cube allows only comp6 output on pin PA10, usart1 rx then on pin PB7; need wire to connect.

And from rm see possible internal connections:

AScha3_1-1716902675313.png

-> no internal connection to any uart - so not possible by internal mux .

Now try to set "manually" the connection comp6 output on pin PA10 and usart1 rx :

from ds -> af settings:

AScha3_2-1716903264082.png

and sett to port register:

AScha3_3-1716903315548.png

Decide yourself : how to set AFR10 to 7 and 8 at same time ?

So Cube is "right" here, only one position of internal pin mux possible.

And you lost the bet...  🙂

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

10 REPLIES 10
AScha.3
Chief

Try to set it in Cube, then you see : possible - or not.

You can set maybe two input mux on same pin, lets say two ADCs on same pin.

Or set a pin as COMP output and ...

AScha3_0-1716883818136.png

see table in ds.  PA2 :

AScha3_1-1716884035946.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Cube won't allow it...but I'm informed it doesn't let you do everything. I'm too new to know if it an be done outside Cube.

So read in rm , what you can set on the registers...then you see, whats possible and if there is any combination, that you cannot set in Cube. (Usually you can set everything in Cube, thats possible.)

>but I'm informed it doesn't let you do everything.

Right, for example you cannot "overclock" the core - Cube only allows settings according to datasheet  rating.

If you feel a post has answered your question, please click "Accept as Solution".
@AScha.3 wrote:

 (Usually you can set everything in Cube, thats possible.)


Many ordinary features can't be configured by CubeMX. For example attach external interrupt on pin used by another peripheral (for example timer input etc.). 

Similar, or the same, situation is discussed there:
https://community.st.com/t5/stm32-mcus-products/stm32g-opamps-routing-to-adc-and-to-comparator/td-p/297032

 


@Michal Dudka wrote:


Similar, or the same, situation is discussed there:
https://community.st.com/t5/stm32-mcus-products/stm32g-opamps-routing-to-adc-and-to-comparator/td-p/297032


Not even similar : if internal mux connection not possible, need to use external wire to connect pins.

Cube cannot change, whats on the chip - you also cannot set, whats not possible. 

I see no "problem" with Cube here.

 

If you feel a post has answered your question, please click "Accept as Solution".

If i read it correctly the link, PHard ask if it is possible to enable opamp output to pin and to connect the same pin to comparator input and adc input. That looks almost the same like  KHarb.1 question if it is possible to connect opamp output to PB11 and use same pin as comparator input. It should be possible and moreover cube MX allow it (teste on similar chip, green "+" sign in cubeMX).

more interesting question is about comparator and UART... and i bet it is possible too ... I'll try it when I have time.

more interesting question is about comparator and UART... and i bet it is possible too ... 

I just tried, on F303 :

AScha3_0-1716902404973.png

Cube allows only comp6 output on pin PA10, usart1 rx then on pin PB7; need wire to connect.

And from rm see possible internal connections:

AScha3_1-1716902675313.png

-> no internal connection to any uart - so not possible by internal mux .

Now try to set "manually" the connection comp6 output on pin PA10 and usart1 rx :

from ds -> af settings:

AScha3_2-1716903264082.png

and sett to port register:

AScha3_3-1716903315548.png

Decide yourself : how to set AFR10 to 7 and 8 at same time ?

So Cube is "right" here, only one position of internal pin mux possible.

And you lost the bet...  🙂

If you feel a post has answered your question, please click "Accept as Solution".

You are right. Comparator output is digital and thus it has assigned corresponding AF.

Only way is to use opamp as comparator, then for example OPAMP6 share pin PB11 with USART3_RX.

I changed my design such that COMP > UART internal connection would be very useful. Can you confirm your hunch?