Ports in Assembly

Technical questions regarding the XTC tools and programming with XMOS.
diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Ports in Assembly

Post by diltsman »

I am trying to do the embedded hello world program (flash LEDs) in assembly. I know that I need to get deal with a port, but I am a bit confused about how to do that.

GETR says that ports cannot be allocated (page 105 of XMOS XS1 Architecture). Section 15.2 of the same document says to use SETC to configure the port. When I look up SETC(I) I see that it takes two parameters, and register and either a register or immediate value. The immediate value (s) appears to be one of the CTRL_ constants in the section. The register (r) appears to be some type of resource identifier. I can see that that is returned from GETR for most resource types, but how do I get that for a specific port?


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

Post by segher »

GETR does not make sense for ports, because you never want just
any port, you want a specific one.

For ports you use constants for the resource identifiers. In assembler,
you have to load that constant into a register first, of course.

For example, port 1A is 0x10200; if you include <xs1.h>, you can
use the nice symbolic name XS1_PORT_1A.
diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Post by diltsman »

Thanks! I can look up port constants in xs1.h. Are these constants documented anywhere else?
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

See for example http://www.xmos.com/published/xs1-ports-specification,
which I found using Google since the website doesn't seem to link to
it anymore (I couldn't find the architecture book either; something is
somewhat messed up perhaps).

But you should probably use the symbolic names, or the names from
your XN file.