USIC TX FIFO question

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

cross mob
User10696
Level 4
Level 4
First solution authored
I am using the USIC on the XMC4500 as a UART. I have configured it to use the TX FIFO with a depth of 16.
The XMClib supplies a function to write to the FIFO (XMC_USIC_CH_TXFIFO_PutData()), but this function does not block when the FIFO is full. The extra data just gets lost.
I have a solution where I check the FIFO before each PutData with the XMC_USIC_CH_TXFIFO_IsFull() function, but this seems very clumsy. Is there a better way to use the FIFO?
0 Likes
7 Replies
chismo
Employee
Employee
First like received
Hello,

I would suggest to use the standard transmit buffer interrupt (STBI).

For example, with the XMC lib in DAVE4, the following code configures for:
- TXFIFO of 32 words starting from word location 0
- A limit value of 1
- Enables the standard transmit buffer event for interrupt generation
XMC_USIC_CH_TXFIFO_Configure(XMC_SPI0_CH1, 0, XMC_USIC_CH_FIFO_SIZE_32WORDS, 1);
XMC_USIC_CH_TXFIFO_EnableEvent(XMC_SPI0_CH1, XMC_USIC_CH_TXFIFO_EVENT_CONF_STANDARD);

With this, it means that a STBI is triggered every time the TXFIFO level transitions from 1 to 0.
For a use case example, assume the transmit frame is 128 words.
The flow will be:
1) Load the first 32 words.
2) Wait for interrupt
3) The TXFIFO level will be decremented as each word gets transmitted until it hits the limit value and go below, which triggers the STBI.
4) In the interrupt routine, load the next 32 words and wait for interrupt again.
5) Once all 128 words are written (count the number of interrupts), no further writes are needed.

Regards,
Min Wei
0 Likes
User10696
Level 4
Level 4
First solution authored
Thank you for this solution, I will try it.
Why is this sort of information not put in the documentation of the XMClib. The documentation only lists the functions and the user has to guess how to use them best. A few examples how to use the library for each peripheral would be very useful.

Regards
Adrian
0 Likes
Not applicable
amanning wrote:
Thank you for this solution, I will try it.
Why is this sort of information not put in the documentation of the XMClib. The documentation only lists the functions and the user has to guess how to use them best. A few examples how to use the library for each peripheral would be very useful.

Regards
Adrian


it is actually explained in the reference manual as I did the same.
0 Likes
User10696
Level 4
Level 4
First solution authored
The transmit buffer events are described in chapter 17.2.8.2, but from this description I could not work out how to implement the code using the XMClib functions. A simple example in the XMClib documentation would be useful. The Application Note AP32303 does not show an example of the transmit FIFO either.
0 Likes
AngelB
Employee
Employee
Hi amanning,

you have a UART TX FIFO example in the provided AP32303-Example Code package that you can download from the Infineon web page by clicking in "AP32303-XMC1000/XMC4000-Universal Serial Interface Channel(USIC)- Example Code".
The project is named: "XMCLib_UART_FIFO"

Best regards,
Angel
0 Likes
User10696
Level 4
Level 4
First solution authored
The FIFO example in the application note (and the example code) do not use the interrupt. The FIFO is used but only to write some data and read it back in the loop back mode. This is not a realistic application.
To demonstrate the use of the FIFO and interrupt a different example is needed. Why not write an example like chrismo wrote above?
0 Likes
AngelB
Employee
Employee
Hello Adrian,

we will add examples using together USIC FIFO and the Interrupt handling.

Best regards,
Angel
0 Likes