2024-05-28 12:13 AM
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?
Solved! Go to Solution.
2024-05-28 06:38 AM - edited 2024-05-28 06:40 AM
> more interesting question is about comparator and UART... and i bet it is possible too ...
I just tried, on F303 :
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:
-> 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:
and sett to port register:
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... :)
2024-05-28 01:12 AM - edited 2024-05-28 01:15 AM
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 ...
see table in ds. PA2 :
2024-05-28 01:19 AM
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.
2024-05-28 01:31 AM
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.
2024-05-28 03:38 AM
@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
2024-05-28 05:02 AM
@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.
2024-05-28 05:50 AM
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.
2024-05-28 06:38 AM - edited 2024-05-28 06:40 AM
> more interesting question is about comparator and UART... and i bet it is possible too ...
I just tried, on F303 :
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:
-> 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:
and sett to port register:
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... :)
2024-05-28 07:56 AM
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.
2024-06-22 01:56 PM
I changed my design such that COMP > UART internal connection would be very useful. Can you confirm your hunch?