Program instructions
7.3 Communication
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
189
Example: Transmit and Receive instructions
MAIN Network 1 Network 1
//This program receives a string of characters until a line feed character
is received. The message is then transmitted back to the sender.
LD SM0.1
MOVB 16#09, SMB30
On the first scan:
1. Initialize Freeport:
- Select 9600 baud.
- Select 8 data bits.
MOVB 16#B0, SMB87 2. Initialize RCV message control byte:
- RCV enabled.
- Detect end of message character.
- Detect idle line condition as the mes-
MOVB 16#0A, SMB89 3. Set end of message character to
4. Set idle line timeout to 5 ms.
MOVB 100, SMB94 5. Set maximum number of characters
ATCH INT_0, 23 6. Attach interrupt 0 to the Receive
ATCH INT_2, 9 7. Attach interrupt 2 to the Transmit
Complete event.
8. Enable user interrupts.
RCV VB100, 0 9. Enable receive box with buffer at
VB100.
INT 0
LDB= SMB86, 16#20
MOVB 10, SMB34
ATCH INT_1, 10
CRETI
NOT
RCV VB100, 0
Receive complete interrupt routine:
1. If receive status shows receive of
end character, then attach a 10 ms
timer to trigger a transmit and return.
2. If the receive completed for any
other reason, then start a new receive.
INT 1
LD SM0.0
DTCH 10
XMT VB100, 0
10-ms Timer interrupt:
1. Detach timer interrupt.
2. Transmit message back to user on
port.