Page 1 of 1

Transmission

Posted: Wed May 19, 2010 12:24 am
by rp181
I am a beginner in XMOS, XC, and even C. I wrote this real quick, using the UART library from xmos.com.

Code: Select all

#include <uart.h>
#include <platform.h>

port tx = XS1_PORT_1A;
port rx = XS1_PORT_1B;

int main(void) {
	chan c;	
	par{
		on stdcore[0] : uart_tx(tx,c);
		on stdcore[1] : uart_rx(rx,c);
	}
}
So would this launch 2 threads, one to read from a pin, and the other to send the read data out?

What I am trying to do is read a NMEA GPS and send it to a wireless transmitter. The GPS is 4800 baud, and the transmitter is 9600. How can i define different serial ports?

Re: Transmission

Posted: Wed May 19, 2010 1:01 am
by lilltroll
Start with checking out the UART_BIT_TIME in the .h file and the .xc file
You will need to use different values for TX and RX.

Re: Transmission

Posted: Wed May 19, 2010 1:26 am
by rp181
If it's one class, how do i have different values? Also, it turns out i am getting an error, saying that uart_tx is an undefined reference (also for rx).

Re: Transmission

Posted: Wed May 19, 2010 8:33 am
by skoe
You have to change the original source code and identify all places where the BIT_TIME is used for tx and where it is used for rx. Then define two different BIT_TIME_RX and BIT_TIME_TX and use them at the right places.

<advertisment>Or you may want to have a look at my UART implementation I posted yesterday. It should be easily customizable once you understood how it works ;)</advertisment>

Re: Transmission

Posted: Wed May 19, 2010 9:32 am
by paul
rp181 wrote:If it's one class, how do i have different values? Also, it turns out i am getting an error, saying that uart_tx is an undefined reference (also for rx).
Erm, looking at your code and judging by the error that you have posted I think that you have not included the appropriate source files.

The XMOS tools don't have a built in UART library however their are several examples around, both on XCore and on XMOS.com (see the UART Tutorial and the code example)

Cheers,

Re: Transmission

Posted: Wed May 19, 2010 2:09 pm
by rp181
How exactly do you add libraries? I have been putting the paths in the project properties.

Re: Transmission

Posted: Wed May 19, 2010 2:34 pm
by lilltroll
At least under windows - you can just drag and drop files.

Open the catalouge with the .h files - click and hold the file and just drag it to your project in the XDE project explorer.

Finally you need to use

#include "uart.h" instead of
#include <uart.h>

when using external .h files.
Like this - where I use the external iis.h

Code: Select all

#include <platform.h>
#include <xclib.h>
#include <assert.h>
#include <print.h>
#include <stdlib.h>
#include "iis.h"