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.
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.
It is available since PCAN-Basic version 4.3.0.
This parameter is read/write. It can be configured and retrieved.
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.
|
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).
Get: The PCAN Channel must be initialized before using this parameter.
Set: The PCAN Channel must be initialized before using this parameter.
The following code shows how to configure all the digital Pins of a USB Channel:
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);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01
If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
Dim pinMask As UInteger = &H1F
If Api.SetValue(channelUsed, PcanParameter.IoDigitalConfiguration, pinMask) = PcanStatus.OK Then
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}.")
End If
Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;
if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
UInt32 pinMask = 0x1F;
if (Api::SetValue(channelUsed, PcanParameter::IoDigitalConfiguration, pinMask) == PcanStatus::OK)
Console::WriteLine("All digital Pins (0 to 4) of {0} were successfully configured as digital outputs.", channelUsed);
else
Console::WriteLine("Error configuring digital Pins for {0}.", channelUsed);
Api::Uninitialize(channelUsed);
}