2023-12-14 09:15 AM
I am able to transmit data from STM32WL to Arduino UNO board using USART Serial communication but on following the same procedure I am not able to transmit the data from STM32L152RE to Arduino board though baud rate matches and the code and circuit connections are fine.
This is how I configured the port.
And this is my part of the code for USART Communication.
uint8_t tx_buffer[64] = "Hello world \r\n";
while (1)
{
/* USER CODE END WHILE */
HAL_UART_Transmit(&huart1, tx_buffer, 8, HAL_MAX_DELAY);
HAL_Delay(100);
/* USER CODE BEGIN 3 */
}
Can anyone recommend what could possibly go wrong in setting up the USART communication using the STM32L152RE board.
2023-12-14 09:53 AM - edited 2023-12-14 09:57 AM
Hello @Subha_shree_bask,
Could you provide the USART setting of the Arduino?
Do the settings match those of the NUCLEO?
This Wiki article might also be helpful
Best Regards
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.
2023-12-14 10:26 PM
Yes, the USART settings of the NUCLEO matches
And the following is my Arduino code (I used the same code which worked for STM32WL)
2023-12-15 01:22 AM - edited 2023-12-19 07:44 AM
Hello @Subha_shree_bask ,
We don't know about other Arduino UART settings: parity, word length etc..
As you already succeeded to communicate with STM32WL, are you sure you had set the same UART parameters for STM32L152 device as for STM32WL? i.e. parity, word length etc ?
Also you need to double check your hardware. Are you sure you have connected UART pins to the right IOs with a common GND?
2023-12-25 06:20 AM
Yes mam I am using the same Arduino code as I used for the STM32WL board, Also the parity and word length I did not the fix anything its a default parameter in the Arduino IDE. Only there is an option to select the baud rate in the IDE.
2023-12-25 12:10 PM
Are you sure that the code in STM is OK? I see there, for example, that HAL_UART_Transmit is call after /* USER CODE END WHILE */ Attach your main.c code as a file so it can be checked. Or try to debug it to make sure that the commands for Tx are called at all. Also note that the Arduino UNO uses 5V logic while the STM32 uses 3.3V logic. And it would also be good to check with an oscilloscope or a logic analyzer if any signal is generated on the STM32 pins (whether the assignment is correct).
2023-12-25 12:57 PM
Forward out a different Serial port.
Serial is presumably the USB Serial of the Arduino.
Define the port and pins used by the Arduino for the connectivity you're complaining about.
2023-12-25 01:57 PM
Implement error handling in your code. Check for errors in the USART communication using the HAL_UART_Transmit() return value.
2023-12-28 01:42 AM
Yes the STM Code is fine because I tried the same lines for STM32WL55 board, and instead of Arduino UNO I tried with ESP8266 NodeMCU it works fine.
And I used the same code for STM32L152RE code and connected the STM board with ESP8266, which uses 3.3V logic. When the RX and TX lines are connected with the ESP8266 there is no Serial output it is just stuck
but when I remove the RX and TX wires the output is printed that it received when it was connected.
Again when I am connecting the wires the serial monitor is stuck. I tried using a different Serial Monitor the result is the same. So I guess from STM32L152 board the string is getting transmitted.
I have attached the main.c file that I uploaded for the STM32L152RE board.