DAVE4 UART[4.1.4] App Problem

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

cross mob
Not applicable
Hello,

I gota problem that is driving me crazy. I've created a Dave4 Project and added an UART App. I am using the functions from the UART APP Help menue.
I want to jump into an if clause when a number of bytes have been received.

//Receive 10 bytes of data
if(UART_Receive(&UART_0, ReadData, 2) == UART_STATUS_SUCCESS)
{
//Retransmit the received 10 bytes
UART_Transmit(&UART_0, ReadData, 2);
}

this is working so far. Now I want to receive different data with different count of length over UART.

in my main function the main while loop contains 3 more while loops for data receiving. Loop 1 should only be left when 2 bytes were received. If loop 1 has been left then loop2 is entered. loop 2 waits for 4 bytes.
loop 3 is expecting 4 bytes and can only be entered if loop 2 has received the 4 bytes.

My main looks like that

DAVE_STATUS_t status;
status = DAVE_Init(); /* Initialization of DAVE APPs */
C_UART_Init(UART1,19200, 16);
uint8 ucArr1[2];
uint8 ucArr2[4];
uint8 ucArr3[4];
while(1U)
{
while(x < 4)
{
if((!UartReceive(UART1, &ucArr1, 2) == UART_STATUS_SUCCESS) && (x>1))
{
//Retransmit the received 10 bytes
UartSend(UART1, &ucArr1, 2);
x = 4;
}
if(x < 3)
x++;
}
x = 0;

while(x < 4)
{
if((!UartReceive(UART1, &ucArr2, 4) == UART_STATUS_SUCCESS) && (x>1))
{
//Retransmit the received 10 bytes
UartSend(UART1, &ucArr2, 4);
x = 4;
}
delay_ms(500);
if(x < 3)
x++;
}
x = 0;

while(x < 4)
{
if((!UartReceive(UART1, &ucArr3, 4) == UART_STATUS_SUCCESS) && (x>1))
{
//Retransmit the received 10 bytes
UartSend(UART1, &ucArr3, 4);
x = 4;
}
delay_ms(500);
if(x < 3)
x++;
}
x = 0;
}


I only get the data in the first loop correctly, after that everything goes wrong and the data that has been sent is not received correctly.
Am I doint something wrong or do i need to clear some buffer or something similiar after a received message?

I am using an XMC4500-F144x1024 and Dave v.4.1.4. These are my settings for the UART App

GENERAL SETTINGS
Operation mode: Full Duplex
Desired speed [baud]: 19200
Data bits: 8
Stop bit: 1 Stop Bit
Parity selection: No Parity

ADVANCED SETTINGS
Transmit mode: Interrupt
Receive mode: Interrupt
Oversampling: 16
Enabled transmit and receive FIFO with Size 16

INTERRUPT SETTINGS
Transmit, Receive and Error Handling Interrupt Priority is set to
Preemption priority 63
Subpriority 0

In the Manual Pin Allocator I've set
Receive Pin: #117 (P4.7)
Transmit Pin: #115 (P1.7)
0 Likes
1 Reply
Not applicable
Problem solved

//Wait for reception of bytes
while(UART_1.runtime->rx_busy)
{
}

saved my day 🙂
0 Likes