2021-01-22 05:08 AM
Use case : when an on-off command is received on the node via BLE, the node should send some data to Arduino over USART1. Similarly, when some data is received on the node over USART1, it should publish the data to other boards or a phone.
If I port the UART interrupt code to the above application, the HAL_UART_Receive_IT() keeps giving HAL_BUSY error and no character is received from Arduino.
2021-01-22 05:14 AM
Well you can't keep issuing new HAL_UART_Receive_IT() requests when one is already pending.
You actually need to receive a character, from the UART's perspective, have the IRQ handler dispatch the callback, and then set a new request.
If the UART is not receiving anything, then you need to inspect the clocks, the pins, the Uart configuration and the external wiring.
I'd start by tracing the signal from the source into the UART's RX pin, use a scope, check the form of the signal and the bit rate. Check that the TX side of the UART outputs data in the equivalent manner.
2021-01-24 06:09 AM
Thank you @Community member for your prompt response. I apologize for the delay.
I think I am doing what you are saying. I am using the BLEMeshLightingPRFNode application in which I have ported the UART code in the following way :
In "app_mesh.c" file's Appli_Init(), I called HAL_UART_Receive_IT(&huart1_temp, &ch, 1); (I will refer it as a 'receive API' for the sake of simplicity.)
In the same file, I defined HAL_UART_RxCpltCallback() (callback function) and called the receive API again. But then compilation error occurred saying that the callback function is already defined in hw_uart.c. So I invoked the receive API in that file. But then no loop occurred or reception. I had to disable the friend feature for that. Now the callback is invoked continuously but it always returns an error HAL_BUSY.
-------------------Some clarifications----------------------
2021-02-08 09:38 PM
Hi everyone ! I'd really appreciate if someone can guide me here..
2021-02-10 06:34 AM
It sounds like you are trying to do too many things all at once.
Take a step back, and start with the basics: just get a wired UART connection to a PC working.
2021-02-11 01:19 AM
Thank you @Andrew Neil for the suggestion. I will try that.