PIN_VOLTAGE
The PIN_VOLTAGE function returns the current voltage in millivolts on an XJLink2 pin. Pins can be referenced by their name if they are a PIO pin, by their JTAG function if they are a JTAG pin (i.e. TDI/TDO/TCK/TMS, etc) or else by their number.
PIN_VOLTAGE was added in XJTAG v2.3 and is not recognised in versions prior to that.
Syntax
PIN_VOLTAGE( PIO.pioName )
PIN_VOLTAGE( jtagPin )
PIN_VOLTAGE( INT pinNumber )
Parameters
- pioName
-
The name of a PIO pin.
- jtagPin
-
Any one of the possible JTAG pins: TDI, TDI2 to TDI8, TDO, TDO2 to TDO8, TCK, TCK2 to TCK8, TMS, TMS2 to TMS8, RTCK.
In versions of XJTAG prior to v4.0, the pins TCKb, TCKc and TCKd, and TMSb, TMSc and TMSd were used in place of the numbered TCK and TMS pins. These forms are still supported for backwards compatibility, but will be removed in a future version of XJTAG.
- pinNumber
-
The pin number on the XJLink2 JTAG connector and between 1 and 20. If 0 or greater than 20, a runtime error will occur. Referencing pins by number is only supported on an XJLink2; if an XJLink-PF20 or XJLink-PF40 is being used, then an error occurs.
Return value
An INT value containing the measured voltage in millivolts.Errors
An error can occur in the following circumstances:
- The specified pinNumber is zero or greater than 20 (compile-time or run-time).
- The specified PIO pin is not defined in the pin mapping (compile-time).
Example
// Function to check a PIO pin voltage is within 3% of the expected value when driven high. // Presumes there is a PIO pin called TRST. GLOBAL TestPioVoltage()(INT result) INT expectedVoltage := 3300; // expect 3300 mV INT actualVoltage; SET PIO.TRST := 1; result := RESULT_PASS; actualVoltage := PIN_VOLTAGE(PIO.TRST); PRINT("Voltage read: ",actualVoltage,"mV\n"); IF actualVoltage > expectedVoltage + (3 * expectedVoltage/100) THEN result := RESULT_FAIL; END; IF actualVoltage < expectedVoltage - (3 * expectedVoltage/100) THEN result := RESULT_FAIL; END; END;
See Also
XJTAG v4.1.100