AnsweredAssumed Answered

STM32F072B-Disco HAL Usart problem

Question asked by olejnik.pawel on Jan 6, 2016
Latest reply on Jan 8, 2016 by boehm.matthias
I've been trying to make an application which will send and recieve data via USART on STM32F072B-Disco. I managed to generate a project with cubeMX. So far I only achieved transmitting data, but recieving seems a little bit trickier. Using HAL_USART_Receive() is sending dummy data only. Can I somehow use the function only if the data is being recieved? This is my code:

while (1)
        if (counter>=100000){
        if (counter%10000==0){

USART config is as follows: 

void MX_USART1_Init(void)
  husart1.Instance = USART1;
  husart1.Init.BaudRate = 9600;
  husart1.Init.WordLength = USART_WORDLENGTH_8B;
  husart1.Init.StopBits = USART_STOPBITS_1;
  husart1.Init.Parity = USART_PARITY_NONE;
  husart1.Init.Mode = USART_MODE_TX_RX;
  husart1.Init.CLKPolarity = USART_POLARITY_LOW;
  husart1.Init.CLKPhase = USART_PHASE_1EDGE;
  husart1.Init.CLKLastBit = USART_LASTBIT_DISABLE;

I just need to send a word to the board, I want it to fiddle with it (like cipher or so), and send it back. Any ideas how to make it work? Any piece of code would be appreciated.