X
RSS YouTube LinkedIn Twitter Facebook

Search




Post new topic Reply to topic   [ 3 posts ] 
Author Message
37
PostPosted: Wed May 23, 2012 12:50 am 
Joined: Wed May 23, 2012 12:44 am
Posts: 3
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:
/*
 ============================================================================
 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;
}


Top
Offline Profile View all posts by this user  
 
251
PostPosted: Wed May 23, 2012 2:19 pm 
User avatar
Active Member
Joined: Mon Oct 31, 2011 4:08 pm
Posts: 44
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


Top
Offline Profile View all posts by this user  
 
37
PostPosted: Wed May 23, 2012 5:49 pm 
Joined: Wed May 23, 2012 12:44 am
Posts: 3
Thanks! They are outputted as char bytes as you said. '1' '2' .. worked great.


Top
Offline Profile View all posts by this user  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic   [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests



Search for:
Jump to: