I am trying to read UART and to hold on rx_data array. when I send "AT" to rf module it returns "OK" , but on my code I cannot receive anything from UART. and help appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 4:58 AM
uint8_t tx_data[2] = "AT";
uint8_t rx_data[10];
HAL_Delay(1000);
while (1)
{
HAL_UART_Transmit (&huart1, tx_data, sizeof(rx_data) , 250);
HAL_Delay(500);
HAL_UART_Receive(&huart1,rx_data, 20,1000);
HAL_GPIO_TogglePin (GPIOA, LED_Pin);
HAL_Delay(500);
}
- Labels:
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:07 AM
I tried "AT\r\n" as well , same result , no data from uart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:12 AM
Togles your LED ?
have you initialised UART properly parity num bits speed ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:16 AM
I think so, only changed baud rate to 9600
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:17 AM
note: I use Nucleo L476Lgr. board
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:28 AM
on NVIC Settings have you enabled IRQ USART?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:30 AM
no, I haven't . I don't use interrupt, I am using POLL method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:32 AM
This need too be enabled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:32 AM
Your python code works because python has the UART RX always receiving data and storing it in a buffer. The sleep() call just waits long enough for the radio to respond. The lora.read() simply reads whatever is ALREADY in the buffer. I would also bet that the Lora.write() function appends "\r\n", because every radio/modem I've used that supports the AT command set requires the "\r\n" to terminate the command line (as @TDK​ suggested).
In your original STM32 code you are actually sending 3 bytes: 'A', 'T' and NULL, because you are using sizeof(). "C" appends a trailing NULL to all string literals. Maybe that is confusing the radio?????? Use strlen() instead of sizeof(), and add the trailing "\r\n" to the AT command. And remove the delay between Tx and Rx as mentioned above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:33 AM
even though I use simple uart POLL method still I have to enable this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-23 10:49 AM
with debugger I can see what is inside rx_data and tx_data , I tried both method with/without "\r\n". same , screenshot below
