|Online Development Notebook > Index > Programming Overview > Device Commands > StrobeWrite|
StrobeWrite - Write 8 bits to a port and strobe a control line
This is a function that strobes the write of a byte value to a port. This command selects port A or B for the written byte, as well as a polarity (negative or positive) and a line (A.0 - B.7) to toggle. The byte is written and then the line toggled.
Command Syntax: (USBm.dll)
USBm_StrobeWrite( device, data, port, sel )
The USBm_StrobeWrite function syntax has these parts:
|device||A zero-based index to address the appropriate USB device.|
|dataarray||Data to write.|
|port||The port to write the byte. A value of 00h is port A, a value of 01h is port B.|
|sel||The strobe direction and the strobe 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.
|Public Declare Function USBm_StrobeWrite _|
Lib "USBm.dll" _
(ByVal device As Byte, _
ByVal dataarray As Byte, _
ByVal port As Byte, _
ByVal sel As Byte) _
|USBm_SetBit 1, 15|
USBm_StrobeWrite 1, &H55, 0, &H0F
If a device is connected to the U4xx that will accept a byte of data from port A when B.7 is toggled from high to low and back to high, then the above sample code would write &H55 to 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 write to port A and toggle B.7 low, then high. The breakdown of the first four bytes of the command is: 1 - device, &H55 - data to write, 0 - port to write (A), 15 - 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.
|int USBm_StrobeWrite( unsigned char device, unsigned char data, unsigned char port, unsigned char sel );|
Returns true if successfull, false otherwise. Writes a byte to a port based on a strobing line and timing. the byte data string specifies the setup and so forth.
Hardware: U401 USB Interface U421 USB Interface U451 USB Interface
Programming: USBm DLL Programming Download Files
Application Notes: U4x1 Application Notes Misc Applications and Information FAQ
While every effort has been made to make sure that the information posted on this site is correct, the author can not be held liable for any damages whatsoever for losses as a result of the application of this information. Use this information at your own risk.
USBmicro can design your custom and semi-custom USB product. Email about USB design can be directed to " Robert " at usbmicro.com.
Copyright © USBmicro, L.L.C., 2002-2010