Semaphore application example continued:
FB 1
:A F 10.0
:JC =M001 If no message is active,
:
:AN I 0.0
:BEC
:
:L KH 2222 generate message and
:T FW 12
:AN F 10.0
:S F 10.0 set "MESSAGE" flag.
:
M001 :JU FB10 Call "REPORT" FB
NAME :REPORT
:
:BE
FB 10
NAME :REPORT
:AN F 10.1 If no semaphore is disabled,
:JC FB 100 call "disable semaphore" FB.
NAME :SEMADIS
:
:A F 10.1 If the semaphore is disabled
:AN F 10.2 and the timer has not started,
:S F 10.2
:L KT010.2 start the timer.
:SE T 10
:
:A F 10.2 If the timer has started
:AN F 10.3 and no message is being transmitted,
:JC FB 110 call "output message" FB.
NAME :MSGOUT
:
:A F 10.2 If the timer has started
:AN F 10.4 and the semaphore is not enabled
:AN T 10 and the timer has elapsed,
:JC FB 101 call "enable semaphore" FB.
NAME :SEMAENAB
:
:AN F 10.4 If the semaphore is enabled,
:BEC
:
:L KH0000
:T FY10 reset all flags.
:BE
Continued on next page
Semaphore Operations
CPU 948 Programming Guide
C79000-G8576-C848-04
3 - 79