XC-1 vs XC-2

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
Post Reply
User avatar
ahenshaw
Experienced Member
Posts: 96
Joined: Mon Mar 22, 2010 8:55 pm

XC-1 vs XC-2

Post by ahenshaw »

I have some UART-oriented code that I've been developing on my XC-1 (1v0). I had a bit of a problem at first, but remembering to use "program mode" fixed that right up. I'm talking to the USB serial port on my Windows PC and I can run it with no problems at 115.2 K. Now, that I've received my XC-2 (2v0) development kits, I'm moving my code over to that.

So I start a fresh XC-2 project (I've checked that it is an XC-2 project) and copy the code into it, but the program produces garbled output on the terminal emulator (I've checked the baud rate and other settings). It appears that I can't produce a good bitstream with the XC-2, even when I slow things down to 38400.

I'm not convinced that something hasn't changed with my compiler settings, so I created another fresh XC-1 project and copied the same code into it. I then hooked up my XC-1, put it into "program mode" and started the app. Everything runs perfectly on the XC-1.

Is there some corresponding "program mode" setting for the XC-2 that I'm missing?

Here's the top-level code.

Code: Select all

#include <platform.h>
#include "uartlib.h"

on stdcore[0]: port term_port_rx = PORT_UART_RX;
on stdcore[0]: port term_port_tx = PORT_UART_TX;


void Generator(chanend output) {
    for(int i=0; i < 100000; i++){
    	if (!(i%10000)) {
    	    output <: i;
    	}
    }
}

void Status(chanend input, chanend fromTerminal, chanend toTerminal) {
    int data;
    chputs(toTerminal, "\n\rYellowFin\n\r");
    
    while(1){
    	input :> data;
    	chputi(toTerminal, data);
    	chputs(toTerminal, "\n\r");
    }
}

int main(void) {
    chan toTerm;
    chan fromTerm;
    chan toStatus;
    par {
        on stdcore[0]: uartHandler(toTerm, fromTerm, term_port_tx,  term_port_rx, 38400);
        on stdcore[1]: Status(toStatus, fromTerm, toTerm);
        on stdcore[1]: Generator(toStatus);
    }
    return 0;
}

Here's my uartlib. It's calling into slightly-modified versions of the XMOS uart_1thread code.

Code: Select all

#include "uartlib.h"

void uartHandler(chanend transmitChannel, chanend receiveChannel, 
		         port transmitPort,   port receivePort,
		         unsigned baudrate) 
{
	uart_1thread(transmitPort, transmitChannel, receivePort, receiveChannel, baudrate);
}

void chputs(chanend output, char s[]){
	int i=0;
	while(s[i] != 0){
		output <: (unsigned) (s[i]);
		i++;
	}
}

void chputi(chanend output, int n){
	unsigned msb=1;
	unsigned digit;
	
	if (n < 0) {
		output <: (unsigned)'-';
		n = -n;
	}
	// determine the msb position
	while(n/(msb * 10)) {
		msb *= 10;
	}
	while(msb) {
		// get most significant digit, convert to ascii, and output
		digit = n / msb;
		output <:  digit + (unsigned)'0';
		n -= digit * msb;
		msb /= 10;
	}
}




User avatar
Woody
XCore Addict
Posts: 165
Joined: Wed Feb 10, 2010 2:32 pm

Post by Woody »

You should be able to see the RX and TX data lines on pins 17 and 19 of the XTAG connector if you've got a 'scope. Are the signals as you expect here?
User avatar
otitov
XCore Addict
Posts: 207
Joined: Thu Dec 10, 2009 11:00 pm
Location: Mexico
Contact:

Post by otitov »

might be related to problems I have with UART and XC-2 - http://www.xcore.com/forum/viewtopic.php?f=10&t=301 ?
Post Reply