2024-09-05 10:36 AM
Hey guys!
I'm trying to run the eaxmple found in this link: https://deepbluembedded.com/stm32-serial-port-uart-with-usb-ttl-converter-pc-interfacing/
I'm able to read the data from MCU serially, but when I write, the GPIO is not getting toggled. I've configured the MCU as described. I'm using blackpill v3 board. What I suspect is there is an issue with type conversions. But not sure. It would be very helpful if someone can help me with this.
Thanks in advance!
2024-09-06 07:03 PM - edited 2024-09-14 03:18 AM
I was assuming the LED pin is set to high on reset, and that either condition is supposed to set it low (which turns on the LED). If not, than Chris21's answer may be right on the money.
> I don't have a debugger. I'm using the serial transmit to try printing the value. But still no luck.
You should get one.
if you have serial OUT working, you can use that to send back the received character and examine it that way.
You can also use serial OUT to verify whether the "if" body is being executed.
2024-09-07 08:34 AM
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);
Even If I do the above It's not working!
2024-09-07 08:36 AM
Thanks for your response!
I tried the same code with Nucleo-H723ZG Development Board. Still no luck :(
2024-09-07 09:35 AM
Okay, So I tried debugging the code with debugger. I'm able to see that the if statement is not satisifed. I'm new to STM32 and I'm not sure how to print the values on debugger console. Can anyone please help me with that? Also, check the image for reference:
2024-09-07 02:26 PM
@zeus So are your questions now about Nucleo-H723ZG (with genuine ST-LINK on-board) or black pill?
2024-09-07 08:32 PM
Well, my question is how to make the uart code work as I'm not sure what am I missing. I'm using Nucleo-H723ZG (with genuine ST-LINK on-board) to debug the code as I don't have sepate debugger to test on black pill. So, how can I print the variables in the debugger console while using the st-link onboard?
2024-09-08 10:07 AM
Have you checked if you have connected all signal grounds properly? to test rs232 you can do loopbak. Do loopback towards data source and see if you get back what you transmit.
2024-09-08 10:14 AM - edited 2024-09-08 10:25 AM
What happens if you get any other symbol in the serial line? First chek if your processor gets anything at all, later you can start filtering and processing
You can try HAL_GPIO_TogglePin
2024-09-08 10:50 AM - edited 2024-09-08 11:01 AM
> how can I print the variables in the debugger console while using the st-link onboard?
Two ways. (But none of them prints to the debugger console window like on your screenshot).
1. The onboard ST-LINK usually has internal USB to serial adapter, so called "VCP". On the STM32 side it is connected to one of U(S)ARTs. See your Nucleo user guide to know which UART it is, on which pins.
Then just initialize this UART in "asynchronous mode" and send your output. On the PC side use your favorite terminal program such as Teraterm. CubeIDE also has a serial terminal built in, but IMHO it is less convenient.
2. The onboard ST-LINK can use STM32 feature called ITM. It is basically a sub-channel of the debugger connection that you can use to send output. You need to enable it in the debugger options. The output will go to a special window of CubeIDE or other debugger: "ITM console" or whatever. Like the former, this does not need a separate cable, just the debugger USB cable plugged in. Very convenient.
Please take your time, check the examples, CubeIDE user manual, ST app. notes and your favorite search engine.
2024-09-09 02:32 AM
@Techn I did check the signal grounds and everything is proper. I also tried the HAL_GPIO_TogglePin. It's working fine, also the processor is able to transmit data via UART and I was able to get it printed on CoolTerm.