This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART data loss

Respected all,
This is my first query over this forum so I thank you for your support well in advance.

I am simply trying to use the following "USART_PutChar" function which would send the data bytes via uart4.

Now, my code is calling this "putchar" function each time one of my sensor receives the data.

The function is as follows:


void USART_PutChar(char *ch)
 {

        while((*ch!='\0'))
         {

                        while(!(UART4->SR & USART_SR_TXE));
                                UART4->DR = *ch;
        ch++;

   }

 }

The issue is as follows:
When the data is sent to the sensor on a slower pace, let say twice a second or so, the data is coming fine.
But when this rate increases, there is data loss and the data stops coming.

When I removed this line from the code above,

                        while(!(UART4->SR & USART_SR_TXE));

,

the data starts coming but then the data turns out bit random (full of spaces and all).

Well, this shows that the TX/RX pin is somehow causing the difference.

Can anyone kindly assist me in this regard.

Thanks
Regards

Parents
  • Outputting string, not character.
    Will block for multiple character times.
    Should not be called from interrupt context.

    >>Well, this shows that the TX/RX pin is somehow causing the difference.
    Not seeing anything to support this. What pins are being used? What are you comparing performance/differences against?

    Chip/board being used is not defined. Insufficient code to replicate or provide context.

Reply
  • Outputting string, not character.
    Will block for multiple character times.
    Should not be called from interrupt context.

    >>Well, this shows that the TX/RX pin is somehow causing the difference.
    Not seeing anything to support this. What pins are being used? What are you comparing performance/differences against?

    Chip/board being used is not defined. Insufficient code to replicate or provide context.

Children
No data