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-09 02:33 AM
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!
2024-09-14 02:38 AM
@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!