| Online Development Notebook > Index > Programming Overview > Device Commands > WriteA |
WriteA - Write byte value to port A
Description:
This is a function that writes a byte value to port A when the port is set as an output. The possible values range from 0-255 (00h to FFh).
Command Syntax: (USBm.dll)
USBm_WriteA( device, data )
The USBm_WriteA function syntax has these parts:
| Part | Description |
| device | A zero-based index to address the appropriate USB device. |
| data | Byte to write to Port A. |
Remarks:
Port A 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_WriteA _ Lib "USBm.dll" _ (ByVal device As Byte, _ ByVal data As Byte) _ As Integer |
VB Example
| USBm_WriteA 3, &H55 |
This code fragment writes the value of &H55 to port A of device 3.
C Prototype
| int USBm_WriteA( unsigned char device, unsigned char data ); |
C Example
RobotBASIC
usbm_WriteA(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 | 01h: WriteACmd |
| 1 | Byte Data - This byte is written to port A, D0 - D7 The most significant bit of the byte value is written to D7 |
| 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 A. Byte 2 through byte 7 are unused.
Raw Command Response Format:
| Byte Number | Description |
| 0 | 01h: WriteACmd |
| 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 a E7h to port A with the command 01-E7-00-00-00-00-00-00 will set A.7, A.6, A.5, A.2, A.1, and A.0 high and will set lines A.4 and A.3 low, assuming that they are configured as outputs.
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