Program instructions
7.3 Communication
S7-200 SMART
188 System Manual, 09/2015, A5E03822230-AC
4.
Maximum character count:
The Receive instruction must be told the maximum number of
characters to receive (SMB94 or SMB194). When this value is met or exceeded, the
receive message function is terminated. The Receive instruction requires that the user
specify a maximum character count even if this is not specifically used as a terminating
condition. This is because the Receive instruction needs to know the maximum size of
the receive message so that user data placed after the message buffer is not overwritten.
The maximum character count can be used to terminate messages for protocols where
the message length is known and always the same. The maximum character count is
always used in combination with the end character detection, intercharacter timer, or
message timer.
5.
Parity errors:
The Receive instruction automatically terminates when the hardware signals
a parity, framing, or overrun error; or if a break condition is detected after the start of a
message. Parity errors occur only if parity is enabled in SMB30 or SMB130. Framing
errors occur if the stop bit is not correct. Overrun errors occur if characters come in to
quickly for the hardware to handle. A break condition terminates a message because it
resembles a parity or framing error to the hardware. There is no way to disable this
function.
6.
User termination:
The user program can terminate a receive message function by
executing another Receive instruction with the enable bit (EN) in SMB87 or SMB187 set
to zero. This immediately terminates the receive message function.
Using character interrupt control to receive data
To allow complete flexibility in protocol support, you can also receive data using character
interrupt control. Each character received generates an interrupt. The received character is
placed in SMB2, and the parity status (if enabled) is placed in SM3.0 just prior to execution
of the interrupt routine attached to the receive character event. SMB2 is the Freeport receive
character buffer. Each character received while in Freeport mode is placed in this location for
easy access from the user program. SMB3 is used for Freeport mode and contains a parity
error bit that is turned on when a parity, framing, overrun, or break error is detected on a
received character. All other bits of the byte are reserved. Use the parity bit either to discard
the message or to generate a negative acknowledgement to the message.
When the character interrupt is used at high baud rates (38.4 kbaud to 115.2 kbaud), the
time between interrupts is very short. For example, the character interrupt for 38.4 kbaud is
260 microseconds, for 57.6 kbaud is 173 microseconds, and for 115.2 kbaud is
86 microseconds. Ensure that you keep the interrupt routines very short to avoid missing
characters, or else use the Receive instruction.
Note
SMB2 and SMB3 are shared between Port 0 and Port 1. When the reception of a
character
on Port 0 results in the execution of the interrupt routine attached to that event (interrupt
event 8), SMB2 contains the character received on Port
0, and SMB3 contains the parity
status of that character. When the reception of a character on Po
rt 1 results in the execution
of the interrupt routine attached to that event (interrupt event 25), SMB2 contains the
character received on Port
1 and SMB3 contains the parity status of that character.