unexpected buadrate from "Generic Uart Loopback Example"

If you have a simple question and just want an answer.
richardb
Newbie
Posts: 1
Joined: Thu Nov 13, 2014 12:54 pm

unexpected buadrate from "Generic Uart Loopback Example"

Post by richardb »

I've been trialing the xSOFTip "Generic Uart Loopback Example" on a startkit.

Whilst I can get the loopback to work fine, when I hang a scope probe on the output pin the bit rate (for baud 115200) is approx 7.3 us rather than 8.68us?

Only when I fix the variable  bit_time (in function uart_tx_impl2, within file uart_tx_impl.xc) and do the same fix in the associated _rx_ function do I get a serial stream at a bit rate that my scope (and serial monitor software application) can decode correctly at  baud rate 115200

  unsigned bit_time = 998;
  //unsigned bit_time = XS1_TIMER_HZ / baud_rate;

 

To test further I pulled the serial output code from uart_tx_impl2() into a separate (newly created) project only to find that the timing is as expected for a 100MHz clock

    unsigned bit_time = 998;       gives a bit width of 9.9us


    unsigned bit_time = XS1_TIMER_HZ / baud_rate;         gives a bit width of 8.68 us (baud_rate = 115200)

 

void txByte(){
    char byte= 0x55;
    unsigned baud_rate  = 115200;
    unsigned port_time;
    unsigned pw;
    //unsigned bit_time = 998;
    unsigned bit_time = XS1_TIMER_HZ / baud_rate;
    unsigned tmr_time;
    int stop_bits = 1;

    timer t;
    timer t2;

// trigger a scope
    t2 :> pw;
    trig @ (pw+=40) <: 0;
    trig @ (pw+=30) <: 1;

// start bit (low)
    txd <: 0 @ port_time;
    t   :> tmr_time;

    // Output data bits.
    for (int i = 0; i < 8; i++) {
      tmr_time  += bit_time;
      port_time += bit_time;

      txd @ port_time <: >> byte;

    }

    // Output stop bit (high)
    port_time += bit_time;
    tmr_time += bit_time * (stop_bits + 1);
    txd @ port_time <: 1;
}

I could not see anycode within the xSOFTip "Generic Uart Loopback Example" that modified the clock rate?   Any suggestions to explain the observed behaviour?

many thanks...

srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

Did you get a chance to observe whether you able to receive/send the charatcers as expected when connected to a serial terminal? 

 

Try running the example from

https://www.xmos.com/published/swgpioex ... tart-guide...

 - scoping output from my experiment results in 8.68us bit time @ 115200 baud