XMC2go UART slipped multiple characters problem.

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

cross mob
User10473
Level 1
Level 1
Hi, I'm an XMC2Go user.

I use UART communication to send and receive data between computer GUI and xmc2go kit.
However, there's one problem happened when it comes to sending data to computer GUI.

     Com ----------> xmc2go
[Rx]   "0123"    "0123"
     Com <---------- xmc2go
[Tx]   "0012"    "0123"

I simply tried to receive data and just resend it to the computer, but when I checked the data in GUI,
'0' character was added at the beginning and a chain of the character data were slipped every each data away one character.

In the part of sending data from GUI was fine, but the problem I guess is the part of sending data from xmc2go to GUI.
It doesn't seem to clear the buffer enough before sending the data for any reason, but I don't know why.

Actually the number of the data chain should be 16 characters, so I set FIFO trigger level to 15 each.
Whether I change the trigger level from 1 to 15, it sometimes happened the same problem.

Therefore, I guess the FIFO trigger limit doesn't seem to the problem, but the problem seems to come from the part of Rx buffer.

I want to know how to clear Tx buffer before sending the data.
Could you give me anything to try?

Thank you.
0 Likes
8 Replies
Not applicable
Hi,

I have a similar problem as you do. I am working with the XMC1300 kit and found the same issue in streaming data to the PC.

A few things that has improved things somewhat for me was to use in the APPs of the uart under interrupts settings a transmit callback (call it what you like) and then use this to send data. It is more reliable. If you do not like this method, use the following statement "while(UART_0.runtime->tx_busy){};" to make sure it is fine in sending or receiving data.

As I said, this is only improving things a bit, there still seem to be a issue with the UART peripheral they have.

I am currently considering using xspy to monitor my signals, but I need to save data and it seems that xspy does not support this. If you figure anything else out, please let me know.

Regards
Enigma
0 Likes
chismo
Employee
Employee
First like received
Hello,

As an example, the following line flushes the TXFIFO for the mentioned channel:

XMC_UART0_CH1->TRBSCR = 0x1000;


But in general the TXFIFO depends on the SW to fill it up with the transmit data.
So there might be something in the software flow that is causing the write of the additional 0 to the TXFIFO.

Regards,
Min Wei
0 Likes
User10473
Level 1
Level 1
I applied it to flush TxFIFO in Dave, and I also tried to flush TxFIFO&RxFIFO in the computer GUI (MFC) with the function called PurgeComm(m_hComm, PURGE_ABORT|PURGE_RXCLEAR),
but the problem still happens..
In debug mode of Dave, everything are fine Rx&Tx, but in MFC debug mode, I found a pattern before the problem showed up.
Before the problem happened, when wByte (sending buffer from GUI) sent "012345", for example, then rByte (receiving buffer from Kit) received "" (empty string),
and then the slipped character problem showed up again.

Could you give me any other advice? The way you gave me was helpful, but I still couldn't solve the problem...

Regards
Sean


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hi,

now I feel like I find where the problem came from.
Through the many steps to solve it today, I think the problem comes from RxFIFO buffer in xmc2go.
In MFC, TxFIFO is okay because I checked in debug mode, but I couldn't check the characters in Debug mode of Dave,
because whenever I tried to check the wrong characters in Debug mode of Dave, always the right characters came in.
Therefore, it might seem to come from the kit, because everything are surely working in MFC debug mode, when the problem happens.

I guess the real problem comes from that the RxFIFO buffer doesn't seem to get flushed enough,
so I want to know how to flush RxFIFO buffer in this time.

Could you let me know how to flush it? I applied the similar way with the way you showed me with TxFIFO buffer, but it didn't help.

Regards
Sean
0 Likes
chismo
Employee
Employee
First like received
Hello Sean,

I am sorry, I just realized that I gave you a wrong value to clear the TXFIFO. The TXFIFO Flush bit is on bit 15 of the TRBSCR register so equivalent hex value should be 0x8000 instead of 0x1000 (bit 12 is a reserved bit).
To flush the RXFIFO, the bit is on bit 14, i.e. 0x4000.


XMC_UART0_CH1->TRBSCR = 0x8000; // Flush TXFIFO
XMC_UART0_CH1->TRBSCR = 0x4000; // Flush RXFIFO


Or if you are already using XMC Lib in DAVE4, it is easier (and safer) with the USIC APIs:

XMC_USIC_CH_TXFIFO_Flush(XMC_UART0_CH1); // Flush TXFIFO
XMC_USIC_CH_RXFIFO_Flush(XMC_UART0_CH1); // Flush RXFIFO


Regards,
Min Wei
0 Likes
User10473
Level 1
Level 1
chismo wrote:
Hello Sean,

I am sorry, I just realized that I gave you a wrong value to clear the TXFIFO. The TXFIFO Flush bit is on bit 15 of the TRBSCR register so equivalent hex value should be 0x8000 instead of 0x1000 (bit 12 is a reserved bit).
To flush the RXFIFO, the bit is on bit 14, i.e. 0x4000.


XMC_UART0_CH1->TRBSCR = 0x8000; // Flush TXFIFO
XMC_UART0_CH1->TRBSCR = 0x4000; // Flush RXFIFO


Or if you are already using XMC Lib in DAVE4, it is easier (and safer) with the USIC APIs:

XMC_USIC_CH_TXFIFO_Flush(XMC_UART0_CH1); // Flush TXFIFO
XMC_USIC_CH_RXFIFO_Flush(XMC_UART0_CH1); // Flush RXFIFO


Regards,
Min Wei


Hi, Min

I followed the way you gave me, but the signal always came out wrong value.. it went worse than before.
So, I changed the bit to 0x0000 and 0x2000 and 0x4000 as well, then it came out the right value most of the time, but sometimes still the wrong signal came out.
(around 1-2 times in 50 times)

Could you give me some information how I can check the clear bit in the kit, and if it's a correct way that you suggested, then what should I do to go further.?
Moreover, I also want to know the way of clearing buffer in XMC4500, because I'm going to do the same thing in XMC4500.

Regards
Sean
0 Likes
chismo
Employee
Employee
First like received
Hello Sean,

I created a simple code for the XMC1x00 to:
1) Receive a data set of 32 bytes from PC
2) Echo the same 32 bytes back to the PC


/*********************************************************************************************************************
* HEADER FILES
********************************************************************************************************************/
#include "xmc_gpio.h"
#include "xmc_uart.h"

/*********************************************************************************************************************
* MACROS
*********************************************************************************************************************/
#define LED P0_0

/*********************************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************************/
uint8_t message[32];

/*********************************************************************************************************************
* DATA STRUCTURES
*********************************************************************************************************************/
/* UART configuration */
XMC_UART_CH_CONFIG_t uart_config =
{
.baudrate = 9600U,
.data_bits = 8U,
.frame_length = 8U,
.stop_bits = 1U,
.parity_mode = XMC_USIC_CH_PARITY_MODE_NONE
};

/* UART Tx and Rx Pins */
XMC_GPIO_CONFIG_t rx_pin_config =
{
.mode = XMC_GPIO_MODE_INPUT_PULL_UP,
};

XMC_GPIO_CONFIG_t tx_pin_config =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, // Tx output in ALT7
};

/* GPIO LED pin configuration */
XMC_GPIO_CONFIG_t led_pin_config =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
.output_level= 1U
};

/*********************************************************************************************************************
* LOCAL ROUTINES
*********************************************************************************************************************/

/* USIC0 Interrupt Handler */
void USIC0_1_IRQHandler(void)
{
uint8_t index;

/* Check for SRBI event */
if((XMC_USIC_CH_RXFIFO_GetEvent(XMC_UART0_CH1)&&XMC_USIC_CH_RXFIFO_EVENT_STANDARD)==1)
{
/* Clear SRBI flag */
XMC_USIC_CH_RXFIFO_ClearEvent(XMC_UART0_CH1, XMC_USIC_CH_RXFIFO_EVENT_STANDARD);

/* Read in 32 bytes of data */
for (index = 0; index < 32; index++)
{
message[index] = XMC_USIC_CH_RXFIFO_GetData(XMC_UART0_CH1);
}

/* Echo/transmit the received 32 bytes */
for (index = 0; index < 32; index++)
{
XMC_USIC_CH_TXFIFO_PutData(XMC_UART0_CH1, message[index]);
}

/* Toggle LED */
XMC_GPIO_ToggleOutput(LED);
}

}

/*********************************************************************************************************************
* INITIALIZATION & FUNCTION IMPLEMENTATION
*********************************************************************************************************************/
int main(void)
{
/* Configure UART channel */
XMC_UART_CH_Init(XMC_UART0_CH1, &uart_config);
/* Configure input multiplexor */
XMC_UART_CH_SetInputSource(XMC_UART0_CH1,XMC_UART_CH_INPUT_RXD, 0);

/* Initialize FIFO */
XMC_USIC_CH_RXFIFO_Configure(XMC_UART0_CH1, 32, XMC_USIC_CH_FIFO_SIZE_32WORDS, 31);
XMC_USIC_CH_TXFIFO_Configure(XMC_UART0_CH1, 0, XMC_USIC_CH_FIFO_SIZE_32WORDS, 0);

/* Enable Standard Receive Buffer Event */
XMC_USIC_CH_RXFIFO_EnableEvent(XMC_UART0_CH1, XMC_USIC_CH_RXFIFO_EVENT_CONF_STANDARD);
XMC_USIC_CH_RXFIFO_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_RXFIFO_INTERRUPT_NODE_POINTER_STANDARD, 1);

/* Start UART channel */
XMC_UART_CH_Start(XMC_UART0_CH1);

/* Initialize GPIO */
XMC_GPIO_Init(P1_3, &rx_pin_config);
XMC_GPIO_Init(P1_2, &tx_pin_config);
XMC_GPIO_Init(LED, &led_pin_config);

/* Initialize NVIC */
NVIC_SetPriority(USIC0_1_IRQn, 3U);
NVIC_EnableIRQ(USIC0_1_IRQn);

while(1)
{
/* Infinite loop */
}
}


I am using Docklight evaluation version on the PC and the results are:
1766.attach

Will this help?

Regards,
Min Wei
0 Likes
chismo
Employee
Employee
First like received
Regarding your question, the flush sequences should be working fine.

You can check this easily from a debugger view, e.g.:
- receive n data
- suspend the execution and check that the RXFIFO buffer level (TRBSR.RBFLVL bit field) indicates that the data are in the buffer.
In my code above, I simply place a breakpoint before the RXFIFO read and I see that RBFLVL = 32.

- Flush the RXFIFO now and you will be able to see that RBFLVL is cleared to 0.

Regards,
Min Wei
0 Likes
User10473
Level 1
Level 1
Oh, sorry for late.
Thank you so much

Regards
Sean
0 Likes