USBmicro

Your source for USB electrical device interface products.

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

SetBit

Set a single one of the port bits to 1/high


Description:

This is a function that sets a single bit⁄line high.

Command Syntax: (USBm.dll)

USBm_SetBit( device, bit )

The USBm_SetBit function syntax has these parts:

Part Description
device A zero-based index to address the appropriate USB device.
bit The bit that will be affected.

Remarks:

Bit⁄Line Selection

Byte Value Result   Byte Value Result
00h Affect A.0 (Port A, pin 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

 


VB Declaration

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

VB Example

USBm_SetBit 0, 3

This code fragment sets bit A.3 of device 0.


C Prototype

int USBm_SetBit( unsigned char device, unsigned char bit );

C Example

 


RobotBASIC

usbm_SetBit(ne_DeviceNumber,ne_PinNumber)

Returns true if successful, false otherwise. This function makes high⁄low a particula pin on any of the ports. The pin number is 0 for A0 1 for A1…7 for A7…8 for B0, ….15 for B7.


Raw Command  Format:

Byte Number Description
0 07h: SetBitCmd
1 Data – This is the line to set
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 line to set. Byte 2 through byte 7 are unused.

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

Raw Command Response Format:

Byte Number Description
0 07h: SetBitCmd
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:

The command 07-07-00-00-00-00-00-00 will set lines A.7 high, assuming it is configured as an output.

Documentation

Open all | Close all