Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

Not applicable
Hello,

I tried the UART example project. I was not able to do 2 consecutive 2 strings. The first string in the while loop is displayed the second not.
IDE = Dave 4 with Relax Kit with Teraterm.

Any idea?

Regards
Kurt


My code:

int main(void)
{
uint8_t init_data[] =
"\nPress enter if you want to receive a message\n";
uint8_t send_data[] = "\nHello world!";
uint8_t read_data = 0x0; // Global for USART

DAVE_Init(); /* Initialization of DAVE APPs */

/* Transmit the introduction message */
UART_Transmit(&UART_0, init_data, sizeof(init_data)); // Displayed

while (1U)
{
/* Read the data */
UART_Receive(&UART_0, &read_data, 1);

if (read_data == 0xD)
{
/* Transmit the message */
UART_Transmit(&UART_0, init_data, sizeof(init_data)); // Displayed
read_data = 0x0;
UART_Transmit(&UART_0, send_data, sizeof(send_data)); // Not displayed
read_data = 0x0;
}

}
return 0;
}
0 Likes
3 Replies
User10215
Level 4
Level 4
First like received
Hi Kurt,

The second transmit request gets blocked because you have to wait until the first transmit request is finished. Have a look at the app help (right-click on App-Icon, press App Help then press "Methods"), specifically the documentation of the "UART_Transmit"-Function states an example of how to use the function. There you can see that a while-loop waits for the termination of the transmit-request.

Regards,
Niclas
0 Likes
Not applicable
Hallo Kurt,

just put the following code after your first UART_Transmit in the while-loop.

while(UART_0.runtime->tx_busy);

Regards
Andreas
0 Likes
Not applicable
Thanks to all,

that does the trick. Same apply to receive.

Regards
Kurt
0 Likes