cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX does not handle IO alternate functions and peripherals

Kraal
Senior III

Hello,

I have a project where I use a L010K8 (LQFP32 package).

Let say that you want to keep PA13 and PA14 for SWD debugging and use PA15 as USART2 Tx.

Now PA15 AF4 is USART2 Rx, but this can be swapped in USARTx->CR2.

First point is that Rx/Tx swap is not reflected in the pinout view.

Second and more important issue, USART2 is disabled as long as SWD is enabled. In real life it is not a problem to have USART2 on PA15 and SWD on PA13, PA14. I believe this is due to the fact that USART is expected to have both Rx and Tx pins.

Please ST, CubeMX should handle peripherals on pin by pin basis.

Last thing, with the default MSI clock of 2,1MHz, we can't set a baud rate above 115200 bps. This is because BRR must have a value higher than 16. CubeMX only reports the maximum baud rate we can achieve without explaining why. I believe it would be helpful to explain why we can't achieve higher baud rate.

Using STM32CubeMX 6.0.1, L0 pack 1.11.2

Best regards.

5 REPLIES 5
Khouloud ZEMMELI
ST Employee

Hello @Kraal​ 

Could you please give me more details?

Using the latest CubeMX version, we can have both USART and Debug Serial Wire enabled , also according to DS, PA15 cannot take the USART2_TX signal. So according to which document "PA15 can be swapped in USARTx->CR2" ?

For the last point, I can change the USART Baud Rate to the Maximum "131062 Bits/s" with the daefault MSI Freq " 2097 KHz", Otherwise it can be changed under Clock config (you can use PLLCLK/HSI)

Thanks

Khouloud

Hello @Khouloud ZEMMELI​ 

I would like to know where in the DS it is specified that PA15 cannot be USART2 TX ? It is quite common for the USART peripheral to allow swapping of Tx and Rx, and confirmed by RM0451 p.564 USART main features at the bottom of the page. On top of that I can confirm that it works with the hardware (as expected).

0693W000003QX74QAG.png

See the picture above, PA15 is in yellow, USART2 is in pink and does not allow to be activated at all. Only if SWD is disabled then I can activate USART2 on PA15/PA14. See my ioc file attached.

Regarding last point, I would like that the baud rate explanation "Baud rate must be between 32 bits/s and 131.062 Kbits/s" explain why these limits exist, i.e. BRR must be between 16 and 65535.

Best regards.

Cube and CubeMX naturally caters only for a small subset of the zillion possible combination of settings, so it's limited to the "most common usage cases". Of course it can be expanded indefinitely, given infinite resources... which are obviously not given, as ST currently cannot afford to create even a clean non Cube basic example set (see the rejected request in Ideas).

Btw., I am surprised you use CubeMX at all, after all these years...

JW

Hi @Community member​ 

I completely agree with you.

Don't be surprised, I only use cube to get the I2C timings as it is faster than calculating it myself (I should make an excel sheet for this).

Nonetheless, the example above may give a beginner the incorrect impression that the hardware is not flexible, when in reality it is.

Best regards.

> I only use cube to get the I2C timings as it is faster than calculating it myself (I should make an excel sheet for this).

It's a shame ST don't provide such. Or an online calculator. Or whatever, it's a no-brainer few-liner; forcing users to install Java and javoids is plain wrong.

> Nonetheless, the example above may give a beginner the incorrect impression that the hardware is not flexible, when in reality it is.

This is why Cubes should come with something similar to what I wrote above, as warning.

:D

Jan