Skip to main content
Skip table of contents

4.1.2 - Configuration [U3 Datasheet]

One of the most important operations on the U3 is configuring the flexible I/O as digital or analog. The following 4 IOTypes are used for that:

LJ_ioPUT_ANALOG_ENABLE_BIT
LJ_ioGET_ANALOG_ENABLE_BIT
LJ_ioPUT_ANALOG_ENABLE_PORT //x1 is number of bits.
LJ_ioGET_ANALOG_ENABLE_PORT //x1 is number of bits.

When a request is done with one of the port IOTypes, the Channel parameter is used to specify the starting bit number, and the x1 parameter is used to specify the number of applicable bits. Following are some pseudocode examples:

//Configure FIO3 as an analog input.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_BIT, 3, 1, 0);

//Configure FIO3 as digital I/O.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_BIT, 3, 0, 0);

//Configure FIO0-FIO2 and EIO0-EIO7 as analog, all others as digital. That
//means a starting channel of 0, a value of b1111111100000111 (=d65287), and
//all 16 bits will be updated.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_PORT, 0, 65287, 16);

//Configure FIO2-FIO4 as analog, and FIO5-FIO6 as digital, without
//configuring any other bits. That means a starting channel of 2,
//a value of b00111 (=d7), and 5 bits will be updated.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_PORT, 2, 7, 5);

Because of the pin configuration interaction between digital I/O, analog inputs, and timers/counters, many software applications will need to initialize the flexible I/O to a known pin configuration. One way to do this is with the following pseudocode:

This disables all timers and counters, sets the timer/counter pin offset to 4, sets the timer clock base to 48 MHz (no divisor), sets the timer clock divisor to 0, and sets all flexible I/O to digital. A simpler option is using the following IOType created exactly for this purpose, which does the same thing as the 8 function calls above:

ePut (lngHandle, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 0, 0);
ePut (lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 4, 0);
ePut (lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tc48MHZ, 0);
ePut (lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 0, 0);
ePut (lngHandle, LJ_ioPUT_COUNTER_ENABLE, 0, 0, 0);
ePut (lngHandle, LJ_ioPUT_COUNTER_ENABLE, 1, 0, 0);
ePut (lngHandle, LJ_ioPUT_DAC_ENABLE, 1, 0, 0); //Ignored on hardware rev 1.30+.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_PORT, 0, 0, 16);

ePut (lngHandle, LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0);

There are two IOTypes used to write or read general U3 configuration parameters:

The following constants are then used in the channel parameter of the config function call to specify what is being written or read:

LJ_ioPUT_CONFIG
LJ_ioGET_CONFIG

LJ_chLOCALID //0-255, Default=1
LJ_chHARDWARE_VERSION
LJ_chSERIAL_NUMBER
LJ_chFIRMWARE_VERSION
LJ_chBOOTLOADER_VERSION
LJ_chPRODUCTID
LJ_chLED_STATE
LJ_chU3HV //Reads TRUE if U3-HV. False if U3-LV or hardware version <1.30.

Following is example pseudocode to write and read the local ID:

//Set the local ID to 4.
ePut (lngHandle, LJ_ioPUT_CONFIG, LJ_chLOCALID, 4, 0);

//Read the local ID.
eGet (lngHandle, LJ_ioGET_CONFIG, LJ_chLOCALID, &dblValue, 0);

Currently there is no IOType for configuring all the power-up default settings. However, using low-level functionality you can.

To configure the U3 power-up default settings, first configure your I/O to the power-up default settings you want. This includes the configuration settings on this page, Analog Outputs, Digital I/O and Timers & Counters.

Then use the Raw Output/Input functionality to send/receive (LJ_ioRAW_OUT/LJ_ioRAW_IN) the low-level SetDefaults command/response. SetDefaults causes the current or last used U3 configuration to be stored in flash as the power-up defaults.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.