Master-to-Peripheral
A Communication Block for Master-to-Slave transmissions is defined as an Address byte, optional data bytes, and a CHK byte. A block is limited to a maximum of thirty-six (36) bytes.
The upper five bits (MSB) of the Address Byte will be used for addressing. That is, bits 7,6,5,4,3 of the previous byte description will be used for addressing.
The lower three bits (i.e. 2,1,0) of the Address Byte will contain peripheral specific commands. This will allow up to eight instructions to be embedded in the first byte of a block.
The VMC Master will respond to data from a peripheral with an Acknowledgment (ACK), Negative Acknowledgment (NAK), or Retransmit (RET). These are defined later in the document. The 5 mS time-out (t-response) described in the Bus Timing section of this document is the equivalent of a NAK.
If the addressed Slave does not respond within the 5 mS time-out (silence), the Master may repeat the same command, or send a different command, until it receives an answer or until the end of the Non-Response time, as defined in the peripheral sections. See Example in 2.5D. The RESET command should not be used as a recovery method to a 5 mS time-out (t-response) until after exceeding the Nonresponse time. The VMC may send commands to any other peripheral during this time.
Peripheral-to-Master
A Communication Block for Slave-to-Master transmissions consists of either a data block and a CHK byte, a acknowledgment (ACK), or a negative acknowledgment (NAK).
The 5 mS time-out (t-response) described in the Bus Timing section of this document is the equivalent of a NAK command. In addition, it is recommended that the peripheral use this time-out as the NAK when a reception error of the ADDRESS byte occurs. This will prevent several peripherals from trying to simultaneously respond with a NAK.
A data block consists of one or more data bytes followed by a CHK byte. The CHK byte is defined later in this document.
The data block and CHK byte are limited to a maximum size of 36 bytes.
A CHK byte is not required when a peripheral responds with NAK or ACK byte. ACK and NAK are defined later in this document.
The peripheral must set the mode bit on the last byte sent to signify end of transmission. This will be either the CHK byte of a block, a NAK byte, or an ACK byte. The mode bit must not be set except for the conditions above.
A peripheral response of ACK or NAK signifies the end of the exchange.
When a peripheral responds with a data block, the VMC must respond with an ACK, NAK or RET. If the Master cannot respond within the 5 mS time-out (t-response) the peripheral must repeat the data block, or append it, at the next possible occasion (i.e. to a later POLL). The same behavior is to apply when the Master responds with NAK.
CHK Byte
A CHK byte must be sent at the end of each block of data. The CHK byte is a checksum calculated by adding the ADDRESS byte and all DATA bytes. The CHK byte is not included in the summation. The carry bit for CHK additions is ignored since the CHK byte is limited to eight bits.
The following example shows a CHK byte calculation for a possible response to a STATUS command sent to a USA changer slave. See section 5 for details of byte meanings.
----------------------------------------------------
02H Changer feature level
00H Country code for USA
01H Country code for USA
05H Coin scaling factor
02H Decimal place
00H Coin type routing
07H Coin type routing
01H Coin type 0 has value of 1 scaling factor
02H Coin type 1 has value of 2 scaling factor
05H Coin type 2 has value of 5 scaling factor
14H Coin type 3 has value of 20 scaling factor
FFH Coin type 4 is a token
----------------------------------------------------
12CH Therefore the CHK byte would be equal to 2CH
A checksum will be performed on all full blocks of communication. A checksum will not be performed on ACK, NAK, or RET bytes.
Response Codes
The following codes are reserved for the ACK, NAK and RET bytes:
ACK 00H (acknowledgment/checksum correct)
RET AAH (Retransmit the previously sent data. Only the VMC can transmit this byte)
NAK FFH (Negative acknowledge) The VMC and peripheral must also recognize the 5mS time-out (t-response) as a NAK.
NOTE:
To improve system reliability it is recommended that when receiving ACK, NAK, or RET the receiving device counts the number of bits set in the byte. This method will require at least two bit errors in the byte before the byte can be mis-interpreted.
Bus Reset
The VMC may reset all peripherals by pulling the transmit line “active” for a minimum of 100 mS. This informs all peripherals to abort any activity and return to its power-on reset state. Details of this state for each peripheral are provided in later sections of this document. It is recommended that the VMC re-initialize each peripheral after this type of reset.
标签:Format,MDB,NAK,peripheral,CHK,will,ACK,byte,Block From: https://www.cnblogs.com/utank/p/17217984.html