Skip to main content
LRPS_92
Associate III
June 3, 2015
Question

Need Clarification on USART's in STM32f0

  • June 3, 2015
  • 2 replies
  • 511 views
Posted on June 03, 2015 at 09:16

Hello,

                I working on USART in stm32f0-discovery board, in that USART keeps on sending a character 'c'..But i intended to write a code it sends the character 'c' whenever it receives 'a' ....Why it is happening like tat, my code is

void usart_access(void)

{

    

             unsigned char ab=USART_ReceiveData(USART2);

             if(ab == 'a')

             {

            while (USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET);

            USART_SendData(USART2,'c');

             }

            

}

The USART_access function called in the while(1) loop.

#stm32f0-usart
This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
June 3, 2015
Posted on June 03, 2015 at 15:21

Wait for RXNE before receiving the character, and TXE before sending the response.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
LRPS_92
LRPS_92Author
Associate III
June 26, 2015
Posted on June 26, 2015 at 15:10

Thanks for your help clive!!.