发布于 2003-06-12 10:09:26
0楼
Special Memory Bytes 86 - 94 and 186 - 194 are used to control and read status on the Receive Message instruction.
SM Byte
(Read/Write) Des cription
Port 0 Port 1
SMB86 SMB186 Receive message status byte
n: 1 = Receive message was terminated by user disable command
r: 1 = Receive message terminated: error in input parameters or missing start or end
condition
e: 1 = End character received
t: 1 = Receive message terminated: timer expired
c: 1 = Receive message terminated: maximum character count achieved
p: 1 = Receive message was terminated because of a parity error
SMB87 SMB187 Receive message control byte
n: 0 = receive message function is disabled; 1 = receive message function is enabled.The enable/disable receive message bit is checked each time the RCV instruction is executed.
x: 0 = ignore SMB88 or SMB188; 1 = use the value of SMB88 or SMB188 to detect
start of message.
y: 0 = ignore SMB89 or SMB189; 1 = use the value of SMB89 or SMB189 to detect
end of message.
z: 0 = ignore SMW90 or SMB190; 1 = use the value of SMW90 to detect an idle line condition.
m: 0 = timer is an inter-character timer; 1 = timer is a message timer.
t: 0 = ignore SMW92 or SMW192; 1 = terminate receive if the time period in SMW92
or SMW192 is exceeded.
bk: 0 = ignore break conditions; 1 = use break condition as start of message detection.
The bits of the message interrupt control byte are used to define the criteria by which the message is identified. The start of message and end of message criteria are defined. To determine the start of a message, either of two sets of logically ANDed start of message criteria must be true and must occur in sequence (idle line followed by start character or break followed by start character). To determine the end of a message, the enabled end of message criteria is logically ORed. The equations for start and stop criteria are given below: Start of Message = il * sc + bk * sc End of Message = ec + tmr + maximum character count reached
Programming the start of message criteria for:
1. Idle line detection: il=1, sc=0, bk=0, SMW90>0
2. Start character detection: il=0, sc=1, bk=0, SMW90 is a don't care
3. Break detection: il=0, sc=0, bk=1, SMW90 is a don't care
4. Any response to a request: il=1, sc=0, bk=0, SMW90=0 (Message timer can be used to terminate receive if there is no response.)
5. Break and a start character: il=0, sc=1, bk=1, SMW90 is a don't care
6. Idle line and a start character: il=1, sc=1, bk=0, SMW90>0
7. Idle line and start character (illegal): il=1, sc=1, bk=0, SMW90=0Note: Receive will automatically be terminated by an overrun or a parity error (if enabled).
SMB88 SMB188 Start of message character.
SMB89 SMB189 End of message character.
SMB90SMB91 SMB190SMB191 Idle line time period given in milliseconds. The first character received after the idle line time has expired is the start of a new message. SMB90 or SMB190 is MSB (Most Siginificant Byte) and SMB91 or SMB191 is LSB (Least Significant Byte).
SMB92SMB93 SMB192SMB193 Inter-character/message timer timeout value given in milliseconds. If the time period is exceeded, the Receive message is terminated. SMB92 or SMB192 is MSB and SMB93 or SMB193 is LSB.
SMB94 SMB194 Maximum number of characters to be received (1 to 255 bytes).
Note: This range must be set to the expected maximum buffer size, even if the character count message termination is not used.