cancel
Showing results for 
Search instead for 
Did you mean: 

complement or replace CubeMX?

po221
Senior

Hello

I am using CubeIde and cubeMx on a project for several years with no issues.

But I am facing today a limit of CubeMx:
On a STM32L431RCTx I need to have UART2_RX on PA15 and PA2 as GPIO_EXT, not as UART2_TX. CubeMX forces me to have PA2 as UART2_TX :(

I also can't easily use "USER CODE BEGIN/END" areas because CubeMX uses elseif which I can't split (see attached image)

1) Is there a trick to mixing MX setups and personal setups (and this "elseif" not nice)?
2) Is it better to configure everything manually? if so, what is the best practice?

Thank you very much in advance

PS : I'm using CubeID3 1.13 with STM32Cube FW_L4 V1.18.0

22 REPLIES 22
AScha.3
Chief II

and can you (i dont have this chip, but all similar ) define in Cube half duplex? then only one pin is used.

AScha3_0-1690101780054.pngAScha3_1-1690101823077.png

 

 

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

I would have loved

I would have loved to do like that but when I put PA15 in UART2_RX, UART2 is not configurable (red mode)

Thanks

yepp, on half duplex the "TX" pin is used, pa2 here. but now you get pa15 free to use...for exti.

or try alternate pin: first set uart ...as it wants. pa2+15 . then hold ctrl key and click mouse on the pa2 pin + hold key, then blinking all possible alternative pins. if this is something you like, just click on the alternative pin and select ...uart..here. then it uses this pin.

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

Selecting half duplex MX selects PA2!

PA2 in the only pin for USART2_TX and MX persists in selecting this pin when USART2 is selected.

If we put PA2 in reset state USART2 is automatically disabled.

Same behavior with USART3.

It seems that MX does not allow to use an UART for RX only. For me it's a bug... Because I commonly do it without using MX.

po221
Senior

Yes, no alternative for USART2_TX and I don't have free pin

po221
Senior

I imagined 2 solutions to bypass CubeMX:
1) Check "Do not generate the main" in Cube MX and rebuild a main that uses some of what CubeMX generated and some of my own code.
2) Let CubeMx generate the initializations and override at the end with my own modifications

Could one of these solutions be the correct one? what else ?

if Cube otherwise doing good job for you, i would keep it,

and set uart as it likes.

then after init in main you write to port mode (MODER..) and switch mode for pa2 -> input.

and set exti 2 . and write void EXTIx_x_IRQHandler(void) in xxxit.c .

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

For normal mode selecting "Receive Only" or "Transmit Only" doesn't release the respective unneeded pin. For "Single Wire (Half-Duplex)" mode enabling the "TX and RX Pins Swapping" doesn't move the single allocated pin from Tx pin to Rx pin, which is what the hardware actually does. That's just what RubeMX is. And what's the point of all of this contraption? The HAL broken bloatware cannot receive USART stream without ridiculous hacks anyway. Toss it all away and develop a useful and working code:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

 

CubeID3

How can "E" be misunderstood for "3"? Does your eyesight mirror some single letters?

There's ID3 in my company name, fingers go faster than eyes

I'll attempt an overload of what CubeMX does.
Little by little the overload will be able to take more and more things from cubeMX.