IoDigitalConfiguration

This parameter is used to configure the output mode of all digital Input / Output Pins available on a device. It allows the configuration of up to 32 Pins, as a bit mask value.

  Note

At the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version equal to or greater than 3.3.0, support the configuration of a maximum of 5 digital Pins. For this reason, all other (unused) bits are automatically discarded from the bit mask value.

No error is generated by setting a bit for a nonexistent Pin.

Availability

It is available since PCAN-Basic version 4.3.0.

Supported By

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter has a resolution of a double-word (range [0...MaxValue]). It is a bit mask, in which every bit represents a digital input. Bit0, the least significant bit, corresponds to Pin0; Bit1 corresponds to Pin1, and so on until Pin31.

Each digital input Pin of the device can be set as digital output.

Bit value

Description

0

The Pin works as digital input.

1

The Pin works as digital input and digital output.

Default Value

The default value for each Pin (and so for the whole mask) is 0, meaning that all Pins are configured as digital input only (no digital outputs active).

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to configure all the digital Pins of a USB Channel:

C#
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint pinMask = 0x1F;
    if (Api.SetValue(channelUsed, PcanParameter.IoDigitalConfiguration, pinMask) == PcanStatus.OK)
        Console.WriteLine($"All digital Pins (0 to 4) of {channelUsed} were successfully configured as digital outputs.");
    else
        Console.WriteLine($"Error configuring digital Pins for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}

See Also