UART Problems

New to XMOS and XCore? Get started here.
JohnRobert
Active Member
Posts: 34
Joined: Fri Nov 02, 2012 8:10 am

UART Problems

Post by JohnRobert »

G'day,

I've been trying to experiment with the CMUCam (http://cmucam.org/), I've got it working on previous chips, but I've been trying to get it working on XMOS.

On the camera's booting it should dump a message over the RX pin, so I have this code set up to *hopefully* catch the chars coming out:

Code: Select all

#include <xs1.h>
#include <print.h>

# define BIT_RATE 19200
# define BIT_TIME XS1_TIMER_HZ / BIT_RATE

in  port RXD = XS1_PORT_1A;

void txByte(out port txd, int byte)
{
	unsigned time;
	txd <: 0 @ time;
	for (int i = 0; i < 8; i++) {
	time += BIT_TIME;
	txd @ time <: >> byte;
	}
	time += BIT_TIME;
	txd @ time <: 1;
	time += BIT_TIME;
	txd @ time <: 1;
}

char rxByte(in port rxd)
{
	unsigned byte, time;
	rxd when pinseq (0) :> void @ time;
	time += BIT_TIME / 2;
	for (int i = 0; i < 8; i++) {
	time += BIT_TIME;
	rxd @ time :> >> byte;
	}
	time += BIT_TIME;
	rxd @ time :> void;
	return (byte >> 24);
}

void main(){
	printstrln("CMUCam Output");
	printstrln("==================");
	while (1){
		printcharln(rxByte(RXD));
	}
}
But... Nothing in the console output.

Links:

Command Reference:
http://cmucam.org/attachments/download/ ... st-102.pdf

Product Home:
http://cmucam.org/projects/cmucam4

Hardware:
XC-1A
CMUCam v4

I have the XC-1A's 1A (first port in prototyping area) hooked up to the RX pin of the camera.

Any ideas are greatly appreciated!

Thanks,

John

EDIT: To test I boot up the XMOS, upload the code, then restart the camera. The camera is receiving power and functioning, this I know because the TV output is working (stuff is showing on the TV).
Last edited by JohnRobert on Fri Feb 15, 2013 1:03 am, edited 1 time in total.


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

You do see those two lines in your console?

printstrln("CMUCam Output");
printstrln("==================");
JohnRobert
Active Member
Posts: 34
Joined: Fri Nov 02, 2012 8:10 am

Post by JohnRobert »

Sorry, I should have said that, yes I do, that is the only console output.
User avatar
franksanderdo
Experienced Member
Posts: 69
Joined: Sat Apr 30, 2011 6:19 pm

Post by franksanderdo »

Hi John,

on a quick view I don't see any trouble with the code.
Even though this does not say the code is ok (I am novice even more then you are) I would have a closer look with an osciloscope if there is any Signal coming. Just to be sure that the wiring ok.

If that is ok you have 2 ways of checking that your code is working:
a) use another output pin to which you set equal to the input pin. There you can measure that the right information reaches your code
b) print each "bit value" to console. This most probably will disturb the timing, but it helps to see if and (partially) what information reaches your code.

Reagards
Frank
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Hi John,

Nothing in your code resets the cmucam, so it is quite possible that
it is just sitting there, waiting for input. Try sending it some nonsense
commands (or real ones) so it will talk to you?
JohnRobert
Active Member
Posts: 34
Joined: Fri Nov 02, 2012 8:10 am

Post by JohnRobert »

Will do.

On a quick note, I don't have an oscilloscope :(
JohnRobert
Active Member
Posts: 34
Joined: Fri Nov 02, 2012 8:10 am

Post by JohnRobert »

Just had a big "Doh!" moment... Realized that I was plugging the "RX" pin of the camera into the designated "RX" pin on the chip... So I was listening on the RX pin of the camera, instead of TX, and now I'm getting phesible results.

Sorry for this...
User avatar
franksanderdo
Experienced Member
Posts: 69
Joined: Sat Apr 30, 2011 6:19 pm

Post by franksanderdo »

Hi John,

you would not be able to imagine how many times I did the same ;-)
No worries, this is why I said have a look on the signal.
I only have a cheap osciloscope just good good enough to see that there are changes in the signal.
It helped me already 1391 times (more or less) ;-)

Good to know it works now.
Regards
Frank