Transmission

New to XMOS and XCore? Get started here.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Transmission

Postby rp181 » Wed May 19, 2010 12:24 am

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?
User avatar
lilltroll
XCore Expert
Posts: 955
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Postby lilltroll » Wed May 19, 2010 1:01 am

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.
Probably not the most confused programmer anymore on the XCORE forum.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Postby rp181 » Wed May 19, 2010 1:26 am

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).
User avatar
skoe
Experienced Member
Posts: 94
Joined: Tue Apr 27, 2010 10:55 pm

Postby skoe » Wed May 19, 2010 8:33 am

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>
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Postby paul » Wed May 19, 2010 9:32 am

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,
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Postby rp181 » Wed May 19, 2010 2:09 pm

How exactly do you add libraries? I have been putting the paths in the project properties.
User avatar
lilltroll
XCore Expert
Posts: 955
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Postby lilltroll » Wed May 19, 2010 2:34 pm

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"
Probably not the most confused programmer anymore on the XCORE forum.

Who is online

Users browsing this forum: No registered users and 2 guests