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;
}