Frames#

A frame is the smallest unit transmitted between the Host and the NCP. A frame is composed of a Control Byte, possibly a Data Field (depending on the frame type), a 2-byte CRC, and a Flag Byte.

The following figure illustrates the general format used by all ASH frame types.

General ASH Frame FormatGeneral ASH Frame Format

Control Byte#

The Control Byte identifies the type of frame and contains various bit fields as shown in the following table. Subsequent sections provide detailed information on the different frame Control Bytes.

Frame Type Data Field Size (Bytes) Sent By Control Byte Value (Bit Field)
b7 b6 b5 b4 b3 b2 b1 b0
DATA varies: 3-128 NCP, Host 0 frmNum reTx ackNum
ACK 0 NCP, Host 1 0 0 res nRdy ackNum
NAK 0 NCP, Host 1 0 1 res nRdy ackNum
RST 0 Host 1 1 0 0 0 0 0 0
RSTACK 2 NCP 1 1 0 0 0 0 0 1
ERROR 2 NCP 1 1 0 0 0 0 1 0
  • frmNum - DATA frame’s 3-bit sequence number

  • ackNum - acknowledges receipt of DATA frames up to, but not including, ackNum

  • reTx - set to 1 in a retransmitted DATA frame; 0 otherwise

  • nRdy – host sets to 1 if to inhibit the NCP from sending callbacks frames to the host (always 0 in frames sent by the NCP)

  • res - reserved for future use: may be either 0 or 1

Data Field#

The Data Field carries information for DATA, RSTACK, and ERROR frame types. The length of the Data Field is two (2) bytes for RSTACK and ERROR frame types. For DATA frames, the length of the Data Field is variable and sized to fit the EZSP frame being sent.

CRC#

A 16-bit CRC is computed on all bytes in a frame preceding the CRC, excluding bytes added by byte stuffing. The standard CRC-CCITT (g(x) = x16 + x12 + x5 + 1) is initialized to 0xFFFF. The most significant byte precedes the least significant byte (big-endian mode).

Flag Byte#

A Flag Byte, 0x7E, marks the end of a frame. Consecutive Flag Bytes after the first Flag Byte are ignored.

Frame Lengths#

The length of a frame is at least four bytes—Control Byte, two CRC bytes, and a Flag Byte—plus the length of the Data Field, if any:

  • RST, ACK, and NAK frames are 4 bytes long (no Data Field).

  • RSTACK and ERROR frames are 6 bytes long (2-byte Data Field).

  • DATA frames range from 7 through 132 bytes long (3- to 128-byte Data Field).

Frame Numbers#

DATA frames are numbered using 3-bit sequence numbers that count up from 0 to 7 and then wrap back to 0. They are used to acknowledge properly received frames and allow detection of a missing frame. The frame number is assigned when a frame is first sent, and stays the same if the frame is retransmitted.