AnsweredAssumed Answered

Problem with UART HAL DRIVER function.

Question asked by Juanjojy on May 25, 2015
Latest reply on May 29, 2015 by Juanjojy
Hi, i was trying to learn how to use the UART from m stm32f429DISCO, starting with a simple polling program that reads a caracter from pc and retransmit it. (i've reviewed reference manual, datasheet and the description of hal drivers pdf) but can't find the reason why the HAL_UART_Receive(); doesnt change the rxbuffer at all.
I use abother board as usb to 232 converter  and coolterm to send the data.

I've used cubeMX to configure UART 7 port and verified how it set my GPIOF pins 6 and 7 as RX and TX. I've checked the uart configuration matching in my coolterm and the program. and used the solution suggested by Heisenberg in https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fBest%20way%20to%20use%20HAL%20UART%20Receiver%20IT%20Function&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=4963

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"


/* USER CODE BEGIN Includes */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart7;

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_UART7_Init(void);

int main(void)
{



  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();


  /* Configure the system clock */
  SystemClock_Config();


  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_UART7_Init();


  /* USER CODE BEGIN 2 */


  /* USER CODE END 2 */


  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
 
  uint8_t aTxBuffer[2];
     
     aTxBuffer[0]=0x30;
     aTxBuffer[1]=0x31;
     uint8_t aRxBuffer[2];
     HAL_StatusTypeDef UARTStatus;
     
while (1){
          UARTStatus =  HAL_UART_Receive(&huart7,(uint8_t *)aRxBuffer, 2, 5000); 
          
          while((UARTStatus != HAL_OK) || (UARTStatus != HAL_TIMEOUT)){
          aTxBuffer[0]=aTxBuffer[0]+aRxBuffer[0];
          aTxBuffer[1]=aTxBuffer[1]+aRxBuffer[1];
          UARTStatus2=HAL_UART_Transmit(&huart7,(uint8_t*)aTxBuffer,2, 5000);
          while((UARTStatus2 != HAL_OK) || (UARTStatus != HAL_TIMEOUT)){
                }
               
          HAL_UART_Receive(&huart7,(uint8_t *)aRxBuffer, 2, 5000); 
          }
          
  }//fwhile 


}//FMAIN
----------------

The program is supposed to change what is shown on the terminal in some way but i keep getting the eternal 0101010101
and it doesnt change no matter how many keys i press... any ideas of what im doing wrong?






Outcomes