cancel
Showing results for 
Search instead for 
Did you mean: 

Black pill serial communication not working!

zeus
Associate II

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!

This discussion is locked. Please start a new topic to ask your question.
22 REPLIES 22

Thanks a lot @Pavel A. For the detailed explanation. I'll try doing the things you mentioned and see if I'm able to find where the thing is going wrong and then get back to you!

@Pavel A. I was able to debug the code using ITM and found that the data was not getting received as expected. But after changing the logic like this it started working.

if (HAL_UART_Receive(&huart1, &rx_data, 1, HAL_MAX_DELAY) == HAL_OK) {
		HAL_UART_Transmit(&huart1, &rx_data, 1, HAL_MAX_DELAY);
		if(rx_data == 'F'){
			HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);
		}
		if(rx_data == 'S')
		{
			HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);
		}

Thanks a lot everyone for your inputs! My issue got resolved! 

mƎALLEm
ST Employee

Hello,

ST resources are dedicated to supporting genuine ST products. We are not committed to ensuring that clones/fakes work properly with the firmware we provide.

Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.