2024-05-04 02:10 PM - last edited on 2024-05-06 12:11 AM by Peter BENSCH
Hello and thank you in advance.
I am trying to set up a nucleo-wl55jc1 to send UART data to a custom pcb I made. I will post both IOC files as well as the necessary code to help. I can send data one way (from the pcb to the nucleo) but the other direction, is not working.
IOC file for nucleo, I am using usart1 for communication between boards, and usart2 for coms to PC for debugging.
IOC file for custom hardware. Note that the uart pins were initially for the STLINK, however, due to some design changes, they are being used to communicate between boards.
Here is the code for the receiver that just runs in main. Using the live expressions I can see the data coming in.
int UART_ReceiveAndPrint(UART_HandleTypeDef *huart)
{
while(1)
{
if(HAL_UART_Receive(&huart1, rx_buff, 10, 1000)==HAL_OK) //if transfer is successful
{
__NOP(); // toggle LED
// printf("received data\n");
//You need to toggle a breakpoint on this line!
} else {
__NOP();
}
}
return 0;
}
void UART_SendFixedStringEveryFiveSeconds(UART_HandleTypeDef *huart)
{
const char *str = "Hello, UART Receiver!"; // Hardcoded test string
uint16_t len = strlen(str); // Calculate the string length
while (1) { // Infinite loop to send the string continuously
if (len > 0) {
// Transmit the string over UART
HAL_UART_Transmit(huart, (uint8_t *)str, len, 1000); // 1000 ms timeout
}
HAL_Delay(5000); // Wait for 5 seconds
}
}
Here is the transmitter code that.
I have RX->TX and TX->RX and GND->GND for the boards.
Viewing the Live Expressions for the RX Buffer I can see
But the new data isn't coming in every 5 seconds and the RxBuff seems to randomly update with random values every once in awhile.
I tried to follow the STM basic UART tutorial, but cannot get it to work.
2024-06-02 01:40 PM
Hello @jflaxman
Can you test the UART transmission from the Nucleo is happening (using a logic analyser or oscilloscope) if so, try to test reception on the PCB side.
Best Regards.
STTwo-32
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.