XC-1 Tutorials: UART - having problems

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
MosMax
New User
Posts: 3
Joined: Wed May 23, 2012 12:44 am

XC-1 Tutorials: UART - having problems

Postby MosMax » Wed May 23, 2012 12:50 am

I am following the XC-1 tutorial "Interface with a host using a serial link".

I am having problems displaying output through the terminal. What is a good terminal emulator to use? At the moment, I am using the one in Putty. I am on the right COM6 port at the right speed 115200, but I do not see any received messages in the terminal window when running the program.

Thanks

Here is my current code:

Code: Select all

/*
 ============================================================================
 Name        : xc1-uart.xc
 Description : UART code for the XC-1 board
 ============================================================================
 */

#include <platform.h>

#define BIT_RATE 115200 //rate
#define BIT_TIME XS1_TIMER_HZ / BIT_RATE //time = time/sec divided by bit/sec = time/bit

void txByte(out port TXD, int byte);

out port TXD = PORT_UART_TX; // setting up TXD to be the port

int main() {
   txByte(TXD, 0);
   txByte(TXD, 1);
   txByte(TXD, 2);

  return 0;
}

void txByte(out port TXD, int byte) {
  unsigned time;
  timer t;

  /* get initial time */
  t :> time;

  /* output start bit */
  TXD <: 0;
  time += BIT_TIME;
  t when timerafter(time) :> void;

  /* output data bits */
  for (int i=0; i<8; i++) {
    TXD <: >> byte;
    time += BIT_TIME;
    t when timerafter(time) :> void;
  }

  /* output stop bit */
  TXD <: 1;
  time += BIT_TIME;
  t when timerafter(time) :> void;
}
User avatar
Lele
Active Member
Posts: 51
Joined: Mon Oct 31, 2011 4:08 pm
Contact:

Postby Lele » Wed May 23, 2012 2:19 pm

Beware 0, 1, 2 are not printable chars by terminals, try '0', '1', '2' or 0x30, 0x31, 0x32.
Also check that COM6 is the right one.
Lele
MosMax
New User
Posts: 3
Joined: Wed May 23, 2012 12:44 am

Postby MosMax » Wed May 23, 2012 5:49 pm

Thanks! They are outputted as char bytes as you said. '1' '2' .. worked great.

Return to “Development Tools and Programming”

Who is online

Users browsing this forum: No registered users and 9 guests