ring-buffered uart

Technical questions regarding the XTC tools and programming with XMOS.
schmiedl
Junior Member
Posts: 7
Joined: Wed Jul 13, 2011 3:38 pm

ring-buffered uart

Post by schmiedl »

Hi,

I'm currently writing a program for the XK-1A, that gets data via uart and processes them in some way (adjust servo-values). As I have a lot of timing-problems, I'm trying to decouple uart-speed from data-processing speed with a ring buffer thread.
The slow thread (data processing) gets data from the ring buffer only on request. The ring buffer is being filled by the uart-rx-loop.
Unfortunately the data isn't dumped out properly. Sending "abcdefghijklmnopqrstuvwxyz0123456789" generates the output:
received a = 0x61
received \376 = 0xfe

The code is attached. Thanks for your help!

With kind regards,
Chris
You do not have the required permissions to view the files attached to this post.
User avatar
Interactive_Matter
XCore Addict
Posts: 216
Joined: Wed Feb 10, 2010 10:26 am

Post by Interactive_Matter »

Hi,

I perhaps cannot help you with your problem. But perhaps distract you with an alternative solution.

Why do you want to use a ring buffer? Wouldnt' a simple FIFO buffer do the same thing?

In the XMOS Led Tile Application there is a solution for a similar problem. There you have a buffer for packets:

https://github.com/xcore/sw_led_tile_co ... /pktbuffer

Perhaps this solution can help you - or you can derrive a solution for your problem from that code?

Hope it helps

Marcus
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

Interactive_Matter wrote:Hi,

I perhaps cannot help you with your problem. But perhaps distract you with an alternative solution.

Why do you want to use a ring buffer? Wouldnt' a simple FIFO buffer do the same thing?

In the XMOS Led Tile Application there is a solution for a similar problem. There you have a buffer for packets:

https://github.com/xcore/sw_led_tile_co ... /pktbuffer

Perhaps this solution can help you - or you can derrive a solution for your problem from that code?

Hope it helps

Marcus
That FIFO you link to is in fact implemented using a ring buffer :)
schmiedl
Junior Member
Posts: 7
Joined: Wed Jul 13, 2011 3:38 pm

Post by schmiedl »

thanks for your replies. after hours of pain with channels, i now use a shared array. i still don't understand, why the code doesn't work, but it's time to go on now. when i find a solution for decoupled uart, i'll let you know.