Configuring a port as output using lib_xcore Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
michaelf
Junior Member
Posts: 6
Joined: Thu Mar 14, 2024 7:44 pm

Configuring a port as output using lib_xcore

Post by michaelf »

I'm just trying to translate a piece of code from XC to C, and I would like to confirm some functionality when configuring a port.

XC code:

Code: Select all

buffered out port:32 buffered_output_port = /* port */;
C code so far:

Code: Select all

port_t buffered_output_port = /* port */;
port.start_buffered(buffered_output_port, 32);
// how can I now change it from an "in" port (as is the default) to an "out" port?
I see that there is a function

Code: Select all

port_set_inout_data
, but the docs are ambiguous (I think there's a missing word):

Code: Select all

inline void port_set_inout_data(port_t __p)
Set a port drive out the data value (default state).

Parameters:
__p – Port to change the mode of.
.

Does called "set_port_inout_data(port)" set the port as an output port?
View Solution
User avatar
xhuw
Verified
Member++
Posts: 22
Joined: Wed May 22, 2024 2:36 pm

Post by xhuw »

hey, `port_set_inout_data` sets the port to "DATAPORT" mode, i.e. normal operation. This does nothing unless you have previously called `port_set_out_clock` or `port_set_out_ready` as "DATAPORT" is the default mode.

More on this in section 15.2 from the architecture manual https://www.xmos.com/download/The-XMOS- ... ecture.pdf
how can I now change it from an "in" port (as is the default) to an "out" port?
Use the `port_out` or `port_out_at_time` functions from <xcore/port.h>

Code: Select all

port_t buffered_output_port = /* port */;
port_start_buffered(buffered_output_port, 32);
port_out(buffered_output_port, 0);
XMOS Software Engineer

Image