Programming considerations, Syntax – Echelon I/O Model Reference for Smart Transceivers and Neuron Chips User Manual

Page 183

Advertising
background image

I/O Model Reference

173

Programming Considerations

For 8-bit pulsewidth output, the data type of

output-value

for the io_out( )

function is an unsigned short. An

output-value

of 0 results in a 0% duty cycle. A

value of 255 (the maximum value allowed) results in a 100% duty cycle. The duty

cycle of the pulse train is (

output-value

/256), except when

output-value

is 255; in

that case, the duty cycle is 100%.

For 16-bit pulsewidth output, the data type of

output-value

for the io_out( )

function is an unsigned long. An

output-value

of 0 results in a 0% duty cycle. A

value of 65535 (the maximum value allowed) results in a 99.998% duty cycle.
The duty cycle of the pulse train is (

output-value

/65536).

Important: Do not use an

output-value

of 1 in combination with clock(0).

Syntax

pin

[output] pulsewidth [short | long] [invert] [clock (

const-expr

)]

io-object-name

[=

initial-output-level

];

pin

Specifies either pin IO_0 (using the multiplexed timer/counter) or IO_1 (using

the dedicated timer/counter).

short | long

Resolution of the data value: short specifies 8-bit pulsewidth output, long

specifies 16-bit. If neither of these options is specified, the pulsewidth I/O
object defaults to the 8-bit (short) mode.

invert

Causes the output signal to be inverted, normally high for a 0% duty cycle.
By default, the output signal is normally low for a 0% duty cycle.

clock (

const-expr

)

Specifies a clock in the range 0 to 7, where 0 is the fastest clock and 7 is the

slowest clock. The default clock for pulsewidth output is clock 0. The

io_set_clock( ) function can be used to change the clock.

See Appendix A,

Timer/Counter Periods and Resolution

, on page 187, for a

description of how the io_set_clock( ) function affects the resolution and range

of certain timer/counter I/O models.

io-object-name

A user-specified name for the I/O object, in the ANSI C format for variable

identifiers.

initial-output-level

A constant expression, in ANSI C format for initializers, used to set the state

of the output pin of the I/O object at initialization. The initial state is limited
to 0 or 1. The default is 0.

Advertising