Hi everyone, i’m having trouble communicating with my lora E5 grove. I’m using a STM32L476RG.
I’ve got Lora on USART1 and usb on USART2. When I try to write AT commands on USART1 (lora), I don’t get any data sent back.
Here is the code I’m using
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
char command[50] ;
char response[50];
char message1[] = "uart 1 receive\n";
char message2[] = "uart 2 receive\n";
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_RXNE) == SET){
HAL_UART_Transmit(&huart2, (uint8_t*)message1, strlen(message1), HAL_MAX_DELAY);
HAL_UART_Receive(&huart1, (uint8_t*)response, strlen(response), HAL_MAX_DELAY);
HAL_UART_Transmit(&huart2, (uint8_t*)response, strlen(response), HAL_MAX_DELAY);
}
if(__HAL_UART_GET_FLAG(&huart2, UART_FLAG_RXNE) == SET){
HAL_UART_Transmit(&huart2, (uint8_t*)message2, strlen(message2), HAL_MAX_DELAY);
HAL_UART_Receive(&huart2, (uint8_t*)command, strlen(command), HAL_MAX_DELAY);
HAL_UART_Transmit(&huart1, (uint8_t*)command, strlen(command), HAL_MAX_DELAY);
}
}
/* USER CODE END 3 */
}
```