how to use partout

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
jai
Member
Posts: 15
Joined: Wed Jun 15, 2011 9:20 am

how to use partout

Post by jai »

Trying to use partout on a 32bit buffered port.

Code: Select all

out buffered port:32 DataBits = XS1_PORT_32A;
Here i have tried to output a part of the data (8 Bits, i guess its the LSB which will come out)

Code: Select all

partout(DataBits, 8, p1_data);
But this creates an exception.
Unhandled exception: ILLEGAL_RESOURCE, data: 0x00200000
XC Programming manual says:
The number of bits must be less than the transfer width of the port, greater than zero and a multiple of the port width,otherwise an exception is raised.
Here what is wrong with my code?


richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

Since DataBits is initialized with XS1_PORT_32A both the transfer width and the port width are 32bits. The partial output width you have tried to use (8) is not a multiple of the port width (32).

If you want to do a partial output of 8 bits then the port width must be either 1bit, 4bits or 8bits.
User avatar
jai
Member
Posts: 15
Joined: Wed Jun 15, 2011 9:20 am

Post by jai »

Thanks richard, that makes it clear.

I was looking at Programming XC pdf.
On page 63,

Code: Select all

tailBytes = numBytes / 4;
Is this correct? Or is it supposed to be

Code: Select all

tailBytes = numBytes % 4;