Aug 13, 2020
05:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 13, 2020
05:43 PM
I'm trying to figure the best way to approach my problem. Perhaps some experts will weigh in.
Among other communications, I have 2 UARTs I will be running. 1 at about 500 Kbaud & the other at just over 400 Kbaud.
The number of bytes to receive as a packet is somewhat variable, as low 7 bytes to > 16.
So I can't just use UART_Receive. The 2nd byte of the packet is the number of bytes, so I know how many are coming at that point.
Generally I use the DAVE Apps.
Should just drop to a lower level & use XMC libraries and my own Rx ISR?
Can I change the FIFO trigger level on the fly, in the ISR?
Also I using FreeRTOS if that matters.
Among other communications, I have 2 UARTs I will be running. 1 at about 500 Kbaud & the other at just over 400 Kbaud.
The number of bytes to receive as a packet is somewhat variable, as low 7 bytes to > 16.
So I can't just use UART_Receive. The 2nd byte of the packet is the number of bytes, so I know how many are coming at that point.
Generally I use the DAVE Apps.
Should just drop to a lower level & use XMC libraries and my own Rx ISR?
Can I change the FIFO trigger level on the fly, in the ISR?
Also I using FreeRTOS if that matters.
- Tags:
- IFX
12 Replies
Aug 17, 2020
08:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 17, 2020
08:55 AM
Is everyone on vacation?
Aug 17, 2020
12:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 17, 2020
12:11 PM
I don't know about your timing requirements. A straightforward approach could be to set the trigger level to e.g. 8 bytes and set a flag in the ISR. In the idle task you can also check if there is data available in the FIFO (below the trigger level) and set the same flag.
If you want something advanced, look here at this old post.
If you want something advanced, look here at this old post.
Aug 19, 2020
02:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 19, 2020
02:15 PM
Thanks Andrew,
But I still have the problem the UART App is limited to a specific receive size. But I read something about Receive flushing the buffers. So, if I read 2 bytes, then go back and say read 6 bytes, I can lose data in the FIFO.
Is there information on how to use xmclib? examples?
Lets say I have an 8 byte message arriving. I set the FIFO trigger to 2 bytes. In the ISR, I read the 2 bytes and the FIFO is empty (next byte is on its way in). Since the 2 byte is the length, I know 6 byte are coming.
Can I set the FIFO Rx Trigger to 6 bytes now? without losing anything?
Only 2 interrupts in this situation. The ISR would signal the controlling task deal with the Rx buffer.
But I still have the problem the UART App is limited to a specific receive size. But I read something about Receive flushing the buffers. So, if I read 2 bytes, then go back and say read 6 bytes, I can lose data in the FIFO.
Is there information on how to use xmclib? examples?
Lets say I have an 8 byte message arriving. I set the FIFO trigger to 2 bytes. In the ISR, I read the 2 bytes and the FIFO is empty (next byte is on its way in). Since the 2 byte is the length, I know 6 byte are coming.
Can I set the FIFO Rx Trigger to 6 bytes now? without losing anything?
Only 2 interrupts in this situation. The ISR would signal the controlling task deal with the Rx buffer.
Aug 20, 2020
01:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 20, 2020
01:33 AM
I don't think that changing the FIFO will cause a loss of data, but that should be easily confirmed by testing. There are examples in the XMCLib documentation on how to setup UART communication.
Aug 21, 2020
05:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 21, 2020
05:42 AM
I had also the problem of messages with variable byte count. The UART example did not help me, because I don't know how to apply the UART_receive function in this case.
After some tests I found the following simple solution to use the Rx FIFO. It can be part of the endless loop in main(). Code (for only one UART):
//Configure receive FIFO to generate event when one byte is received.
UART_SetRXFIFOTriggerLimit(&UART_0, 0);
static uint8_t rd[21];
static uint8_t index=0;
static uint32_t new_byte_from_fifo=0;
while (1) // mainloop
{
do
{
uint8_t empty;
empty = UART_IsRXFIFOEmpty(&UART_0);
if (!empty)
{
uint8_t new_byte = UART_GetReceivedWord(&UART_0);
rd[index++] = new_byte;
// TODO: what if index gets too large
new_byte_from_fifo = 1;
}
if (new_byte_from_fifo == 1 && empty != 0)
{
new_byte_from_fifo = 0;
// do something with the received data...
UART_Transmit(&UART_0, rd, index); // ...for example
index = 0;
}
} while (new_byte_from_fifo > 0);
}
This has been tested on XMC4500 with messages larger than Fifo size, up to 48 Bytes, at 460800 baud 8n1, Transmit & Receive Mode = Direct, Fifos enabled, each size =16.
A drawback is that this solution does not wait for a certain fill level of the Rx Fifo. Instead, it looks for new bytes as often the main loop allows, which I think is not so elegant.
If there are other solutions, I would be interested to hear about.
After some tests I found the following simple solution to use the Rx FIFO. It can be part of the endless loop in main(). Code (for only one UART):
//Configure receive FIFO to generate event when one byte is received.
UART_SetRXFIFOTriggerLimit(&UART_0, 0);
static uint8_t rd[21];
static uint8_t index=0;
static uint32_t new_byte_from_fifo=0;
while (1) // mainloop
{
do
{
uint8_t empty;
empty = UART_IsRXFIFOEmpty(&UART_0);
if (!empty)
{
uint8_t new_byte = UART_GetReceivedWord(&UART_0);
rd[index++] = new_byte;
// TODO: what if index gets too large
new_byte_from_fifo = 1;
}
if (new_byte_from_fifo == 1 && empty != 0)
{
new_byte_from_fifo = 0;
// do something with the received data...
UART_Transmit(&UART_0, rd, index); // ...for example
index = 0;
}
} while (new_byte_from_fifo > 0);
}
This has been tested on XMC4500 with messages larger than Fifo size, up to 48 Bytes, at 460800 baud 8n1, Transmit & Receive Mode = Direct, Fifos enabled, each size =16.
A drawback is that this solution does not wait for a certain fill level of the Rx Fifo. Instead, it looks for new bytes as often the main loop allows, which I think is not so elegant.
If there are other solutions, I would be interested to hear about.
Sep 02, 2020
10:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2020
10:05 AM
andrew wrote:
I don't think that changing the FIFO will cause a loss of data, but that should be easily confirmed by testing. There are examples in the XMCLib documentation on how to setup UART communication.
Hi Andrew,
Where is the XMCLib documentation?
Where are the Infineon engineers?
Sep 02, 2020
10:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2020
10:14 AM
Hello Infineon engineers ....
Is it just me, or is there a gap in the documentation about interrupts.
For example,
I have a UART, I have it setup and sending data (I can see it on a scope). I want to call an ISR when the FIFO is empty (or close to empty). I'm also using DAVE Apps.
How do I do this? and an explanation of why for each step.
I've read the Interrupt document. It jumps between XMC1000 & XMC4000 with XMC1400 thrown in.
It talks little about the signal flow. And why. Then jumps to optimizations.
Is it just me, or is there a gap in the documentation about interrupts.
For example,
I have a UART, I have it setup and sending data (I can see it on a scope). I want to call an ISR when the FIFO is empty (or close to empty). I'm also using DAVE Apps.
How do I do this? and an explanation of why for each step.
I've read the Interrupt document. It jumps between XMC1000 & XMC4000 with XMC1400 thrown in.
It talks little about the signal flow. And why. Then jumps to optimizations.
Sep 02, 2020
11:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2020
11:56 AM
You can download the latest version of XMCLib here:
http://dave.infineon.com/Libraries/XMCLib/XMC_Peripheral_Library_v2.1.24.zip
In the .zip file you find two .chm files with the documentation. There is also a directory with examples included.
On the XMC1000/4000-series (not specific) product page on the infineon website you can also find examples and appnotes, for example this one:
https://www.infineon.com/dgdl/Infineon-USIC-XMC1000_XMC4000-AP32303-AN-v01_00-EN.pdf?fileId=5546d462...
http://dave.infineon.com/Libraries/XMCLib/XMC_Peripheral_Library_v2.1.24.zip
In the .zip file you find two .chm files with the documentation. There is also a directory with examples included.
On the XMC1000/4000-series (not specific) product page on the infineon website you can also find examples and appnotes, for example this one:
https://www.infineon.com/dgdl/Infineon-USIC-XMC1000_XMC4000-AP32303-AN-v01_00-EN.pdf?fileId=5546d462...
Sep 02, 2020
03:33 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2020
03:33 PM
Hi Andrew,
Thank you!
Too many MLAs. Whats a MLA, a Multi Letter Acronym. too many -- too confusing.
Do you know what the difference is between an event & a trigger event?
For example Transmit/Receive Buffer Status Register (TRBSR), there is the STBI bit or Standard Transmit Buffer Event , but there is also the STBT or Standard Transmit Buffer Event Trigger.
What I'm trying to figure out is : I want to "trigger" the Transmit ISR when 2nd to last data has been transferred fro FIFO to TBUF. So I can refill the FIFO.
Any help is appreciated.
Thank you!
Too many MLAs. Whats a MLA, a Multi Letter Acronym. too many -- too confusing.
Do you know what the difference is between an event & a trigger event?
For example Transmit/Receive Buffer Status Register (TRBSR), there is the STBI bit or Standard Transmit Buffer Event , but there is also the STBT or Standard Transmit Buffer Event Trigger.
What I'm trying to figure out is : I want to "trigger" the Transmit ISR when 2nd to last data has been transferred fro FIFO to TBUF. So I can refill the FIFO.
Any help is appreciated.
Sep 22, 2020
05:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 22, 2020
05:25 PM
I've got UART Interrupts working, but ...
I'm using a do while construct:
do { StreamByte = UART_GetReceivedWord( &UART_SB );
// do stuff quickly
} while ( !UART_IsRXFIFOEmpty( &UART_SB ) );
What I'm finding is that occasionally, I will get an extra character read (erroneously) .
It seems like a timing issue. I've got 6 bytes in the fifo and 7th is in middle of transmitting. The ISR runs due to FIFO trigger level.
As its reading the fifo, then 7th byte arrives and it may read it twice.
Am I doing something wrong? Is there a better way?
I'm using a do while construct:
do { StreamByte = UART_GetReceivedWord( &UART_SB );
// do stuff quickly
} while ( !UART_IsRXFIFOEmpty( &UART_SB ) );
What I'm finding is that occasionally, I will get an extra character read (erroneously) .
It seems like a timing issue. I've got 6 bytes in the fifo and 7th is in middle of transmitting. The ISR runs due to FIFO trigger level.
As its reading the fifo, then 7th byte arrives and it may read it twice.
Am I doing something wrong? Is there a better way?
Jun 02, 2022
01:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 02, 2022
01:29 AM
Hey @User11773,
How do you archived the reception of the UART, can you share your configurations and which pins did you use?
Dec 02, 2020
02:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 02, 2020
02:05 AM
Hey Tim,
i would do this like this:
setfifotrigger to "1" --> ISR when the second byte from your stream is received.
read the first and the second byte -->
rx_byte[0] = getreceivedWord(&UART_xx)
rx_byte[1] = getreceivedWord(&UART_xx)
depends on the rx_byte[1] --> the len of your expected stream size --> setfifotrigger to "rx_byte[1]" to generate the next event when your complet Stream is received.
this works for my situation to 99%.
My case is:
my excpected streams are 1 byte or 6 bytes --> so i set the trigger level to "0" -->
read the first byte and set the trigger level to "4" (for the next 5 bytes) or to "0" when the stream size was only 1byte.
The problem is, when i get the 6byte stream --> the "2." byte is lost (ca. 1 of 1000 events) . I think its also an timing issue or something like else.
best regards
Andi
i would do this like this:
setfifotrigger to "1" --> ISR when the second byte from your stream is received.
read the first and the second byte -->
rx_byte[0] = getreceivedWord(&UART_xx)
rx_byte[1] = getreceivedWord(&UART_xx)
depends on the rx_byte[1] --> the len of your expected stream size --> setfifotrigger to "rx_byte[1]" to generate the next event when your complet Stream is received.
this works for my situation to 99%.
My case is:
my excpected streams are 1 byte or 6 bytes --> so i set the trigger level to "0" -->
read the first byte and set the trigger level to "4" (for the next 5 bytes) or to "0" when the stream size was only 1byte.
The problem is, when i get the 6byte stream --> the "2." byte is lost (ca. 1 of 1000 events) . I think its also an timing issue or something like else.
best regards
Andi