Serial Wombat 18AB Firmware
ProtocolBinaryCommands

Binary Read Pin Public Data Buffer Command

Reads the public data from three consecutive pins starting with a specified pin

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x81 Pin Number 0x55* 'U'* 'U'* 'U'* 'U'* 'U'*

0x55 is recommended, but any byte is acceptable

Response:

Reads the public data from three consecutive pins starting with a specified pin

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x81 Pin Number requested Specified Pin Public Data low byte Specified Pin Public Data High byte Specified Pin + 1 Public Data low byte Specified Pin + 1 Public Data High byte Specified Pin + 2 Public Data low byte Specified Pin + 2 Public Data High byte

Examples:

0x81 0x01 0x55 0x55 0x55 0x55 0x55 0x55

Will read the 16-bit public data from pins 1, 2 and 3. Assuming pin1's public data was 0x481B, pin 2's was 0x38FC, and pin 3's was 0x0314:

Response:

0x81 0x1 0x1B 0x48 0xFC 0x38 0x14 0x03


Binary Set Pin Public Data Buffer Command

Sets the public data for 2 pins. (Pin number can be set to 255 to not set a pin).

The values returned are the values for the public data before it was changed. This can be useful when reading an input's public data value. For instance, when reading the position of a pin set to Rotary encoder mode, the value before being set could be read, then the value set back to 32768 for center.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x82 Pin Number to set Value Low Byte Value High Byte Second Pin to set Second Value Low Byte Second Value High Byte 'U'*

0x55 is recommended, but any byte is acceptable

Response:

Reads the public data from three consecutive pins starting with a specified pin

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x81 Pin Number requested Specified Pin Public Data low byte Specified Pin Public Data High byte 2nd pin number 2nd pin low byte 2nd pin high byte Echo of sent Byte 7

Examples:

0x81 0x01 0x55 0x55 0x55 0x55 0x55 0x55

Will read the 16-bit public data from pins 1, 2 and 3. Assuming pin1's public data was 0x481B, pin 2's was 0x38FC, and pin 3's was 0x0314:

Response:

0x81 0x1 0x1B 0x48 0xFC 0x38 0x14 0x03

Initialize Queue

Initialize a queue in user memory Queue types are as follows:
0 - Byte data queue in RAM 1 - Byte data using shifted QUEUE in RAM (Write only, no read, used for Displays and similar)

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x90 Queue Address LSB Queue Address MSB Size LSB Size MSB Queue Type Varies Varies

Response:

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x90 Queue Address LSB Queue Address MSB Used Size LSB Used Size MSB Queue Type Varies Varies

Examples:

0x90 0x0010 0x0020 0 0 0

Initializes a ram queue of 32 bytes at address 0x0010 in user memory.

Add bytes to queue

Add bytes to a ram queue of bytes. Updates the internal last queue variable with the queue being added to.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x90 Queue Address LSB Queue Address MSB Count of bytes to add (0-4) Byte to Add Byte to Add Byte to Add Byte to Add

Response:

             |BYTE 0          |BYTE 1          |BYTE 2          |BYTE 3          |BYTE 4          |BYTE 5          |BYTE 6          |BYTE 7          |

|:------------—|:------------—|:------------—|:------------—|:------------—|:------------—|:------------—|:------------—| |0x90 |Queue Address LSB |Queue Address MSB |Number added| Queue Result Code | Free bytes after add LSB | Free Bytes after add MSB| 0x55|

Examples:

0x90 0x0010 4 0x31 0x32 0x33 0x34

Add bytes 0x31, 0x32, 0x33, and 0x34 to queue located at 0x0010.

Add bytes to queue

Add 7 bytes to the last written ram queue of bytes.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x92 Byte to Add Byte to Add Byte to Add Byte to Add Byte to Add Byte to Add Byte to Add

Response:

          |BYTE 0          |BYTE 1          |BYTE 2          |BYTE 3          |BYTE 4          |BYTE 5          |BYTE 6          |BYTE 7          |

|:------------—|:------------—|:------------—|:------------—|:------------—|:------------—|:------------—|:------------—| |0x91 |Queue Address LSB |Queue Address MSB |Number added| Queue Result Code | Free bytes after add LSB | Free Bytes after add MSB| 0x55|

Examples:

0x92 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B

Add bytes 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A and 0x3B to queue last added to.

Read Bytes from Queue

Read up to 6 bytes from a given queue

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x93 Queue Address LSB Queue Address MSB Maximum bytes to read Unused Unused Unused Unused

Response :

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x93 Number of Bytes read from Queue Data Byte Data Byte Data Byte Data Byte Data Byte Data Byte
             Note:  If Byte 1 is 5 or less, then byte 7 will contain the last queue result.

Examples:

0x93 0x0170 0x04 0x20 0x20 0x20 0x20

Read up to 6 bytes from queue at address 0x0170

Sample Response: 0x93 0x02 0x34 0x35 0x20 0x20 0x20 0x20

Two bytes were available in the queue. 0x34, and 0x35

               TODO:  Make rx[1] equal to total bytes avaialble or 255

Peek the first byte from the queue without removing it. Get the number of available bytes to read and free space.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x94 Queue Address LSB Queue Address MSB Unused Unused Unused Unused Unused

Response :

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0x94 Queue Address LSB Queue Address MSB Peeked Byte Bytes Available to Read LSB Bytes Available to Read MSB Free Bytes LSB Free Bytes MSB

Note: Ignore peeked value if Bytes Available == 0. Example:

0x94 0x70 0x01 0x55 0x55 0x55 0x55 0x55

Peek byte from queue at address 0x0170

Sample Response:

0x94 0x70 0x01 0x37 0x80 0x01 0xF4 0x01

    Next byte is 0x37 .  384 bytes available to read, 500 bytes Free

Binary Read RAM, 16 Bit address

Reads a byte from an address in Microcontroller RAM. The SW4A and SW4B use 16 bit addresses.

Note that the PIC16F15214 is a Microchip Enhanced Mid-Range chip with both a banked RAM area and a Linear RAM area at an offset address.
See the datasheet for details.

              |BYTE 0          |BYTE 1          |BYTE 2          |BYTE 3          |BYTE 4          |BYTE 5          |BYTE 6          |BYTE 7          |
              |:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|
              |0xA0|Least Significant byte of 16-bit address |Most Significant byte of 16-bit address | 0x55* | 0x55* | 0x55* |  0x55* | 0x55* |
              0x55 is recommended, but any byte is acceptable

Response:

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xA0 Least Significant byte of 16-bit address Most Significant byte of 16-bit address Byte Read From Ram Echoed Echoed Echoed Echoed

Examples:

Read the byte at RAM address 0x0247.

0xA0 0x47 0x02 0x55 0x55 0x55 0x55 0x55

Assuming address 0x0247 held the value 0xAC , Response:

0xA0 0x47 0x02 0xAC 0x55 0x55 0x55 0x55


Binary Read Flash, 32 Bit address, 32 Bit result

Reads two bytes from an address in Microcontroller Flash. The SW18AB uses 32 bit addresses. Due to 24 bit architecture the high byte of a 32 bit word is 0. Multiply the Word Address by 2 to get the byte address.

See the Datasheet for the microchip PIC16F15214 for information on organization

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xA1 Least Significant byte of 32-bit byte address (must be multiple of 4) Middle low byte of 32-bit byte address Middle High byte of 32-bit byte address Most Significant byte of 32-bit byte address 0x55* 0x55* 0x55*

Response:

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xA1 Least Significant byte of 16-bit address Most Significant byte of 16-bit address Echoed Echoed Low Byte Read From Flash High Byte Read From Flash Echoed

Examples:

Read the word at FLASH address 0x010846.

0xA1 0x46 0x08 0x01 0x00 0x55 0x55 0x55

Assuming address 0x0846 held the value 0x07EF , Response:

0xA1 0x46 0x08 0x01 0x00 0xEF 0x07 0x55


Binary Write RAM, 16 Bit address (

Reads a byte from an address in Microcontroller RAM. The SW4A and SW4B use 16 bit addresses.

Note that the PIC16F15214 is a Microchip Enhanced Mid-Range chip with both a banked RAM area and a Linear RAM area at an offset address.
See the datasheet for details.

              |BYTE 0          |BYTE 1          |BYTE 2          |BYTE 3          |BYTE 4          |BYTE 5          |BYTE 6          |BYTE 7          |
              |:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|
              |0xA3|Least Significant byte of 16-bit address |Most Significant byte of 16-bit address | 0 (for 32-bit compatability) | 0 (for 32-bit compatability) | Byte To write |  0x55* | 0x55* |
              0x55 is recommended, but any byte is acceptable

Response:

Echoed Back.

Examples:

Write 0x32 the byte at RAM address 0x0247.

0xA3 0x47 0x02 0x00 0x00 0x32 0x55 0x55


Enable 2nd Command Interface

   This command is only supported on the SW18AB chip.

When in I2C mode by address pin, this enables the UART command interface in parallel with I2C on pins WP7 (TX out) and W9 (RX in). This allows monitoring of the Serial Wombat Chip by a PC or other tool while the chip is also being commanded over I2C

Note that enabling then disabling this feature will leave the UART interface interally connected to pins 7 and 9, however commands will no longer be processed through this interface. A reset is required to fully disconnect internally.

The last 6 bytes must match exactly in order to prevent accidental enabling.

              |BYTE 0          |BYTE 1          |BYTE 2          |BYTE 3          |BYTE 4          |BYTE 5          |BYTE 6          |BYTE 7          |
              |:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|:---------------|
              |0xA5|1 = enable, 0 = disable |0xB2 |0xA5 |0x61 |0x73 |0xF8 |0xA2|

Response:

Echoed Back or error message.

Examples:

Enable 2nd command interface.

0xA5 0x01 0xB2 0xA5 0x61 0x73 0xF8 0xA2


Binary Send 7 bytes out first UART

Queues 7 bytes to be sent out of the first avaialble Hardware UART. Assumes a UART pin mode has already been set up. The host should query avaialble space before using this command.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xB0 1st Byte to Send 2nd Byte To send 3rd Byte To send 4th Byte To send 5th Byte To send 6th Byte To send 7th Byte To send

Response:

Packet is echoed back to the host.

Examples:

Send WOMBAT! out of the UART

0xB0 0x57 0x4F 0x4D 0x42 0x41 0x54 0x21


Binary Read 7 bytes from first UART

Read 7 bytes from the queue of the first avaialble Hardware UART. Assumes a UART pin mode has already been set up. The host should query avaialble bytes to determine the nubmer of bytes avaiable before using this command. This command should only be called if at least 7 bytes are available.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xB1 0x55* 0x55* 0x55* 0x55* 0x55* 0x55* 0x55*

0x55 is recommended, but any byte is acceptable

Response:

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xB1 1st byte read from UART queue 2nd byte read from UART queue 3rd byte read from UART queue 4th byte read from UART queue 5th byte read from UART queue 6th byte read from UART queue 7th byte read from UART queue

Examples:

Assuming GHIJKLM are the first 7 bytes in the UART RX QUEUE:

Sent:

0xB1 0x55 0x55 0x55 0x55 0x55 0x55 0x55

Received:

0xB1 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D


Binary Send 7 bytes out first UART

Queues 7 bytes to be sent out of the first avaialble Hardware UART. Assumes a UART pin mode has already been set up. The host should query avaialble space before using this command.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xB2 1st Byte to Send 2nd Byte To send 3rd Byte To send 4th Byte To send 5th Byte To send 6th Byte To send 7th Byte To send

Response:

Packet is echoed back to the host.

Examples:

Send WOMBAT! out of the UART

0xB2 0x57 0x4F 0x4D 0x42 0x41 0x54 0x21


Binary Read 7 bytes from first UART

Read 7 bytes from the queue of the first avaialble Hardware UART. Assumes a UART pin mode has already been set up. The host should query avaialble bytes to determine the nubmer of bytes avaiable before using this command. This command should only be called if at least 7 bytes are available.

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xB3 0x55* 0x55* 0x55* 0x55* 0x55* 0x55* 0x55*

0x55 is recommended, but any byte is acceptable

Response:

BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6 BYTE 7
0xB1 1st byte read from UART queue 2nd byte read from UART queue 3rd byte read from UART queue 4th byte read from UART queue 5th byte read from UART queue 6th byte read from UART queue 7th byte read from UART queue

Examples:

Assuming GHIJKLM are the first 7 bytes in the UART RX QUEUE:

Sent:

0xB3 0x55 0x55 0x55 0x55 0x55 0x55 0x55

Received:

0xB3 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D