Question
STM32F072B-Disco HAL Usart problem
Posted on January 06, 2016 at 17:01
Hi,
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. UsingHAL_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){
counter=0;
}
if (counter%10000==0){
HAL_USART_Transmit(&husart1,''Hello\n\r'',7,1000);
}
counter++;
HAL_USART_Receive(&husart1,RxBuff,7,1000);
}
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;
HAL_USART_Init(&husart1);
}
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.
#stm32f0-usart-hal-recieve