cancel
Showing results for 
Search instead for 
Did you mean: 

USART echo program not working

shivabhardwaj4
Associate
Posted on November 11, 2012 at 02:08

Hello,

I am trying to implement a simple USART echo program but am running into communication problems between the discovery board and puTTy. When I transmit a character to the discovery board it does not respond. I have my serial adapters transmit line hooked up to a scope which is outputting an 8 bit value in accordance to the configuration of 4800 baud, 1 stop bit and no parity. However even though i can see a signal being sent to the STM i am not quite sure why it does not echo and send a character back.

 

the code I am currently executing is below

int main(void)

{

 

        RCC_Configuration();  //clock initialize for usart2

        //NVIC_Configuration();

        GPIO_Configuration();//pins 2 and 3 configurationaaa

        init_usart();

        STM_EVAL_LEDInit(LED4);

        STM_EVAL_LEDInit(LED5);

    while(1)

        {

             uint16_t Data;

             

            while(USART_GetITStatus(USART2,USART_IT_RXNE) == RESET) ;

            // STM_EVAL_LEDToggle(LED4);

            Data = USART_ReceiveData(USART2); // Collect Char

            while(USART_GetITStatus(USART2,USART_IT_TXE)== RESET); // wait for empty

               USART_SendData(USART2,Data); // defined in stm32f4xx_usart.h 

  }

}

I have even tried just putting   USART_SendData(USART2,0x61) in the main while loop, but instead of the lower case a i should receive I am seeing an 'O' character in puTTy.

Please help me I dont know where I am going wrong!!!

#use-an-oscilloscope
3 REPLIES 3
Posted on November 11, 2012 at 06:02

Please help me I dont know where I am going wrong!!!

So are we supposed to guess with absolutely NONE of the initialization code that might critically impact the functionality?

If the baud timing is wrong, I'd look at the value of HSE_VALUE and how that contrasts with actuality.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pccmd
Associate II
Posted on November 11, 2012 at 18:34

Shiva,

Please post the specific codes for configuration of USART and GPIO pins set for AF, as well as NVIC. Sometimes one small omission will not generate an build error, but render you entire project dead just the same.

Andrew Neil
Evangelist
Posted on November 12, 2012 at 11:19

''I have even tried just putting   USART_SendData(USART2,0x61) in the main while loop, but instead of the lower case 'a' i should receive I am seeing an 'O' character in puTTy''

So what does that tell you?

You said you have an oscilloscope...