cancel
Showing results for 
Search instead for 
Did you mean: 

I am having an issue using a uart receive functions for STM 32 (HAL_UART_Receive). I am trying to get a echo function going(PC-STM-PC) but it seems the PC console displays a different results.

ADeol
Associate

I am sure that the CubeMx settings are fine as the HAL_UART_Transmit works efficiently.

Here is the code I have been using.(ignore extra definitions)

#include "main.h"

#include "stm32l4xx_hal.h"

#include <string.h>

#include <stdlib.h>

#include <errno.h>

#include <signal.h>

#include <math.h>

#include "i2c_comms.h"

int main(void)

{

int retval = 0;

HAL_Init();

SystemClock_Config();

MX_GPIO_Init();

MX_USART2_UART_Init();

while (1) {

char in[8];

HAL_UART_Receive(&huart2, (uint8_t *)in, 8, 1000);

HAL_UART_Transmit(&huart2, (uint8_t *)in, 8, 1);

char test[6] = "check\n";

HAL_UART_Transmit(&huart2, (uint8_t *)test, 6, 100);

}

return 0;

}

void _Error_Handler(char *file, int line)

{

/* USER CODE BEGIN Error_Handler_Debug */

/* User can add his own implementation to report the HAL error return state */

while (1)

{

}

}

I have uploaded the results on the console which gives weird results for whatever input I give it.

0 REPLIES 0