Github vs XMOS

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am
Contact:

Post by rp181 »

I never actually modified the provided UART code. My application was just streaming information (like image data) that constantly refreshed. Because I could see when I missed a byte (value is out of range), I just ignored it - perfectly fine for that application. Even 3M baud worked, but was much less stable.


User avatar
dan
Experienced Member
Posts: 102
Joined: Mon Feb 22, 2010 2:30 pm
Contact:

Post by dan »

There's a 'fast' uart there now with less functionality than the previous one but which runs up to 10 Mbaud, allegedly.

More details here: https://github.com/xcore/sc_uart/blob/m ... ummary.rst

Do let me know what you think (btw, it wasn't me that that wrote it).
nisma
Active Member
Posts: 53
Joined: Sun Dec 13, 2009 5:39 pm

Post by nisma »

I don´t know why there is so bad example and further the need to adverthise the
author and usage of the piece of SW. Sorry for the disagree.
This is a modification , untested, for verify the start bit, normally standard
on software uart implementation.

Code: Select all

void uart_rx(in port pIn, streaming chanend cOut, int clocks) {
    int dt2 = (clocks * 3)>>1;
    int dt = clocks;
    int t;
    unsigned int data = 0;
    while (1) {
        data =0;
        pIn when pinseq(0) :> int _ @ t;
        t += dt2-dt;
        pIn @ t :> >> data;
        if (!data) continue;
#pragma loop unroll(9)
        for(int i = 9; i--; ) {
           t += dt;
           pIn @ t :> >> data;  
        }
        data >>= 23;
        if (data&0x100) continue; /*  TODO: framing error
        pIn @ t :> int _;                 *  output read data now 
                                                  */
        cOut <: (unsigned char) data;
    }
}
For lower speed (3mhz and lower) tx and rx can share one thread.
Post Reply