Rx lane not receiving
Hello,
I try to make an UART communication between Nucleo STM32F030RE and a STM32F030K6 mounted on a custom pcb.
- sends from NUCLEO to STM32F030K6 is OK
- Receive from STM32F030K6 is ok
- sends from STM32F030K6 to NUCLEO is OK (i can check it and decode thanks to oscilloscop)
- Receive from NUCLEO does not work (i used PA10 RX pin of UART1 of NUCLEO)
Here is the code i use for NUCLEO:
int data1 = 0x21 ;
int data2 = 0x22 ;
char *datachar1 = (char*)&data1 ;
char *datachar2 = (char*)&data2;
char *data = (char*)strcat(datachar1, datachar2) ;
char *msg = "KO \n\r";
char *Rxbuffer = NULL ;
int status ;
while (1)
{
HAL_UART_Transmit(&huart1, (uint8_t*)data, strlen(data), 0xFFFF);
status = HAL_UART_Receive(&huart1, (uint8_t*)Rxbuffer, 2, 65000) ;
if ( status == HAL_OK )
{
HAL_UART_Transmit(&huart2, (uint8_t*)Rxbuffer, strlen(Rxbuffer), 0xFFFF); //send to monitor the reception of uart1
} else {
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), 0xFFFF);
}
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5) ; //to visualiy check on the nucleo that the main loop is still running
HAL_Delay(5000) ;
}Basically, NUCLEO UART1 sends 2 hexadecimal commands to STM32F030K6.
STM32F030K6 reads, interprets it and replies in function of the command received.
STM32F030K6 replie is 6 bytes sent to NUCLEO on PA_10 (UART1 Rx).
To check what NUCLEO has received from STM32F030K6, i sent what it has received directly to UART2 which is transmit via usb to a computer to visually read.
If i got a wrong status from the UART1 receive function, i send a readable "KO" status to the computer... which happens all the time.
Any tips ?
Note: whatever the timeout value i put as argument of the HAL_UART_Receive function, the delay time i see thanks to the data monitored is the same. Is it normal ?
