2024-06-26 08:29 AM - edited 2024-06-26 09:18 AM
Hello,
I came across a behavior that I don't understand. In the board's datasheet, I can clearly see alternate function for pin PA3 is USART2_RX but once set, it doesn't work. When I set USART_RX on pin PA15, it works just fine. Can someone explain why it doesn't work? Maybe there are some limitiations which I don't understand or it is MCU malfunction.
2024-06-26 12:20 PM - edited 2024-06-26 12:25 PM
Wow, you're making this more complicated than it is. The Alternate Function settings allow for many pin/peripheral escape options. These obviously get more restrictive in low pin count devices, where the die may have many pads / "pins" they can only bond out those physically attached to the lead frame in the package. The Data Sheet will provide exhaustive detail as to what can connect to what.
You can "use" PA3, it's just not physically connected to the ST-LINK VCP, and consequently "Doesn't Work" in that use case. CubeMX/IDE may offer PA3 as connected too the USART2 peripheral if it lacks awareness of what the board wiring dictates in this instance.
It's the schematic for the board you said you had, and which I linked too and cited in my response.
Why did they choose PA15 for the UART? I don't know, I suppose PA3 was a better choice for ADC support, but PA2/PA3 are exposed at the connectors, so you could use those for a UART, and perhaps not conflict with the ST-LINK/V2-1 VCP support?
2024-06-26 01:31 PM
@a1rWAXTA wrote:cube allows me to assign other functions (for whatever reason?)
Because CubeMX is a general tool - it's not restricted to just the ST development/evaluation tools.
@a1rWAXTA wrote:For example PA15 can be only mapped to usart, and can't be mapped to general purpose input
Not true.
You could make PA15 a general-purpose input but on this board, it would still be connected to the VCP - that is what restricts you when working on this board.
Hence the board provides the solder bridges to allow you to disconnect the VCP if you want to use the pins for other things.