Hello!
I have a brushless DC motor with an appropriate driver (TMCM1640). My K64F communicates via a RS485 transceiver (Artekit RS485/HD) with the RS485 interface of that driver. I am using the uart_nonblocking example code from the KDS library to send data. Uart is configured with the RTS flow control like so:
UART_DRV_Init(UART_INSTANCE_2, &uartState2, &uartConfig); UART_HAL_SetTransmitterRtsCmd(UART2_BASE_PTR, true); UART_HAL_SetTransmitterRtsPolarityMode(UART2_BASE_PTR,true);
(and some other lines...)
In the main loop I use
UART_DRV_SendData(UART_INSTANCE_2, &setTargetCurrentZeroCom , 9u);
while (kStatus_UART_TxBusy == UART_DRV_GetTransmitStatus(UART_INSTANCE_2, NULL)){}
UART_DRV_ReceiveData(UART_INSTANCE_2, &rxChar, 9u);
while (kStatus_UART_RxBusy == UART_DRV_GetReceiveStatus(UART_INSTANCE_2, NULL)){}
to send a 9 byte command and then receive the 9 byte answer from the module. I have two problems with that and maybe this forum can answer them. I get the information, who sends what vie oscilloscope, btw.
1) The command and answer loop goes on a certain amount of times at the 9600 or 115200 Baudrate for example, then it stops. Can be a few commands to a couple of hundreds. But after a while the module sends an answer and the mcu does not get it. Because of the while loops in the main loop the code gets stuck and I see the error --> wait forever to receive. Why would it work for a few times and then stop?
What other information would you need to be able to give advice? Am I missing something simple here?
Thanks,
best regards,
Michael