USBmicro

Your source for USB electrical device interface products.

  • Home
  • Services
    • Design
    • Contact USBmicro
  • Where to buy…
You are here: Home / Documentation / Device Commands / WriteB

WriteB

Write byte value to port B


Description:

This is a function that writes a byte value to port B when the port is set as an output. The possible values range from 0-255 (00h to FFh).

Command Syntax: (USBm.dll)

USBm_WriteB( device, data )

The USBm_WriteB function syntax has these parts:

Description Description
device A zero-based index to address the appropriate USB device.
data Byte to write to Port B.

Remarks:

Port B does not have to have all 8 bits set to output for this to work. You can have a mix of inputs and outputs on the port and this command will set high or low only those lines that are output.


VB Declaration

Public Declare Function USBm_WriteB _
    Lib “USBm.dll” _
        (ByVal device As Byte, _
        ByVal data As Byte) _
    As Integer

VB Example

USBm_WriteB 7, &H0F

This code fragment writes the value of &H0F to port B of device 7.


C Prototype

int USBm_WriteB( unsigned char device, unsigned char data );

C Example


RobotBASIC

usbm_WriteB(ne_DeviceNumber,ne_ByteValue)

Returns true if successful, false otherwise. The byte value is written to Port A⁄B.


Raw Command Format:

Byte Number Description
0 02h: WriteBCmd
1 Byte Data – This byte is written to port B, D8 – D15
The most significant bit of the byte value is written to D15
2 <not used>
3 <not used>
4 <not used>
5 <not used>
6 <not used>
7 <not used>

Raw Command Format Details:

Byte 0 contains the command. Byte 1 contains the data to write to port B. Byte 2 through byte 7 are unused.

Raw Command Response Format:

Byte Number Description
0 02h: WriteBCmd
1 <not used>
2 <not used>
3 <not used>
4 <not used>
5 <not used>
6 <not used>
7 <not used>

Raw Command Response Format Details:

Byte 0 contains the command. Byte 1 through byte 7 are unused.

Raw Command Example Usage:

Writing an 11h to port B with the command 02-11-00-00-00-00-00-00 will set lines B.4 and B.3 high and will set the remainder of the lines low, assuming that they are configured as outputs.

Documentation

Open all | Close all