stdio scanf

New to XMOS and XCore? Get started here.
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

You can use something else instead of the XDE console if your transmitting data via UART.

If you are using a XMOS board with FTDI chip it will enumerate a COM port on your OS. That can be reached from everything from putty.exe to Phyton with serial lib.

I havn't tried scanf, but I reached 2Mbit transfer rate at 400 MHz XCORE, and 3 Mbit @ 384 MHz XCORE using the XMOS port timers talking UART.

(384MHz/4/16*/2)= 3 Mbit which fits with the 6 MHz clock that the FTDI chip is running.
(400MHz/4/25*/2)= 2 Mbit which fits with the 6 MHz clock that the FTDI chip is running.

16* and 25* is the clockdividers for the ports.

The trick is that the bit-rate must fit the rate of the FTDI chip to work, going fast.

This is an example of a fast transmitter.

Code: Select all

void txByte(int bytes[], unsigned size) {
	int byte;
	set_clock_div(clk, CLOCKDIV);
	configure_out_port(TXD, clk, 1);
	start_clock(clk);
#pragma unsafe arrays
	for (unsigned i = 0; i < size; i++) {
		TXD	<: 0; //start bit
		byte=bytes[i];
#pragma loop unroll
		for(int k=0;k<8;k++)
		TXD <: >> byte;
		TXD<: 1; //stop bit
	}
}
(The port TXD was declared as static )


Probably not the most confused programmer anymore on the XCORE forum.