Read 8 bits from a port and strobe a control line
Description:
This is a function that strobes the read of a byte value from a port. This command selects port A or B for the read byte, as well as a polarity (negative or positive) and a line (A.0 – B.7) to toggle. The line is toggled to one state, the byte is read, and then the line is returned to the initial state.
Command Syntax: (USBm.dll)
USBm_StrobeRead( device, dataarray, port, sel )
The USBm_StrobeRead function syntax has these parts:
Part | Description |
device | A zero-based index to address the appropriate USB device. |
dataarray | A byte array where the returned data will be stored. Minimum size of the array must be 1 byte |
port | The port for the byte read. A value of 00h is port A, a value of 01h is port B. |
sel | The strobe direction and the strobe line selection. |
Remarks:
Bit⁄Line Selection
Byte Value | Result | Byte Value | Result | |
00h | Affect A.0 | 08h | Affect B.0 | |
01h | Affect A.1 | 09h | Affect B.1 | |
02h | Affect A.2 | 0Ah | Affect B.2 | |
03h | Affect A.3 | 0Bh | Affect B.3 | |
04h | Affect A.4 | 0Ch | Affect B.4 | |
05h | Affect A.5 | 0Dh | Affect B.5 | |
06h | Affect A.6 | 0Eh | Affect B.6 | |
07h | Affect A.7 | 0Fh | Affect B.7 |
With sel set to the Bit⁄Line Selection values, the strobe is negative-going. By adding 10h to this value, the strobe will be positive-going. For example, 18h would pulse B.0 from low to high, and back low.
VB Declaration
Public Declare Function USBm_StrobeRead _ Lib “USBm.dll” _ (ByVal device As Byte, _ ByRef dataarray As Byte, _ ByVal port As Byte, _ ByVal sel As Byte) _ As Integer |
VB Example
Dim dataarray(1) As Byte USBm_StrobeRead 1, dataarray(0), 0, &H0F |
If a device is connected to the U4xx that will send a byte of data to port A when D15 is toggled from high to low and back to high, then the following commands would read this device.
First set the B.7 line high with USBm_SetBit. The line is set high to begin with because the strobe functions do not initialize the state or direction of the line. (B.7 needs to be set as an output.)
Then toggle B.7 low, read from port A, and toggle B.7 high. The breakdown of the first four bytes of the command is: 1 – device, dataarray(0) – variable to contain result, 0 – port to read (A), &H0F – line to toggle (-F) and toggle direction (0-).
Changing to a positive strobe would necessitate changing the initial line value, and substituting &H1F for the fourth byte.
C Prototype
int USBm_StrobeRead( unsigned char device, unsigned char *data, unsigned char port, unsigned char sel ); |
C Example
RobotBASIC
usbm_StrobeRead(ne_DeviceNumber,se_ByteData)
Returns a byte value of data read from a port based on a strobing line and timing. the byte data string specifies the setup and so forth.
Raw Command
See StrobeRead2