cancel
Showing results for 
Search instead for 
Did you mean: 

Issues trying to get USART writing to a console. It only works when I have stlink connected. As soon as I disconnect stlink the output stops. The output does seem to go through USART2_TX (PA9) as disconnecting it stops the output

Jdu P.1
Associate

I am using STM32L010F4 20 pin on a simple breakout board.

I am running STM32CubeIde and using a STM32Lc100-disco as my programmer via SYS_SWCLK (PA14), SYS_SWDIO (PA13) and NRST.

All works well can get SPI etc running no problem.

I mapped USART2_RX to PA10 and USART2_TX to PA9 and connect this to a serial to USB converter.

Config below

 huart2.Instance = USART2;

 huart2.Init.BaudRate = 115200;

 huart2.Init.WordLength = UART_WORDLENGTH_8B;

 huart2.Init.StopBits = UART_STOPBITS_1;

 huart2.Init.Parity = UART_PARITY_NONE;

 huart2.Init.Mode = UART_MODE_TX_RX;

 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart2.Init.OverSampling = UART_OVERSAMPLING_16;

 huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

Just cannot get output without the stlink connected.

Tried orders of plugging in, restarting, booting desktop, etc. does not work.

1 ACCEPTED SOLUTION

Accepted Solutions
Jdu P.1
Associate

Thanks for your reply. I did re-check the above thanks.

FYI I managed to resolve this.

This turned out to be an issue with the ground between the host pc and the stm32. (Issue on the host side or cable)

Picked it up when I connected the oscilloscope and suddenly everything worked.

Once you disconnect the probe ground pin the issue would occur again.

Never mind what I did ground wise I could not get them to consistently talk.

Resolved/worked around it by putting a raspberry pi in between to communicate to the stm32 via it's UART pins.

View solution in original post

2 REPLIES 2

Make sure BOOT0 is pulled to ground.

Double check all RCC, GPIO and USART clocks/pins are explicitly enabled. ie not left to assumption

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jdu P.1
Associate

Thanks for your reply. I did re-check the above thanks.

FYI I managed to resolve this.

This turned out to be an issue with the ground between the host pc and the stm32. (Issue on the host side or cable)

Picked it up when I connected the oscilloscope and suddenly everything worked.

Once you disconnect the probe ground pin the issue would occur again.

Never mind what I did ground wise I could not get them to consistently talk.

Resolved/worked around it by putting a raspberry pi in between to communicate to the stm32 via it's UART pins.