insn_SI.awl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ORGANIZATION_BLOCK OB 1
  2. BEGIN
  3. // Start timer and let it expire
  4. __STWRST
  5. L 0
  6. SI T 10
  7. SET
  8. R T 10
  9. U T 10
  10. __ASSERT== __STW VKE, 0
  11. SET
  12. L W#16#0010
  13. SI T 10
  14. U T 10
  15. __ASSERT== __STW VKE, 1
  16. L T 10
  17. __ASSERT>= __ACCU 1, 5
  18. __SLEEP 101
  19. U T 10
  20. __ASSERT== __STW VKE, 0
  21. L T 10
  22. __ASSERT== __ACCU 1, 0
  23. // Start timer and reset VKE before it expires
  24. __STWRST
  25. L 0
  26. SI T 10
  27. SET
  28. R T 10
  29. U T 10
  30. __ASSERT== __STW VKE, 0
  31. SET
  32. L W#16#0010
  33. SI T 10
  34. U T 10
  35. __ASSERT== __STW VKE, 1
  36. L T 10
  37. __ASSERT>= __ACCU 1, 5
  38. CLR
  39. L W#16#0010
  40. SI T 10
  41. U T 10
  42. __ASSERT== __STW VKE, 0
  43. L T 10
  44. __ASSERT>= __ACCU 1, 5
  45. __SLEEP 101
  46. U T 10
  47. __ASSERT== __STW VKE, 0
  48. L T 10
  49. __ASSERT== __ACCU 1, __ACCU 2
  50. // Reset signal
  51. __STWRST
  52. L 0
  53. SI T 10
  54. SET
  55. R T 10
  56. U T 10
  57. __ASSERT== __STW VKE, 0
  58. SET
  59. L W#16#0010
  60. SI T 10
  61. U T 10
  62. __ASSERT== __STW VKE, 1
  63. L T 10
  64. __ASSERT>= __ACCU 1, 5
  65. SET
  66. R T 10
  67. U T 10
  68. __ASSERT== __STW VKE, 0
  69. L T 10
  70. __ASSERT== __ACCU 1, 0
  71. __SLEEP 101
  72. U T 10
  73. __ASSERT== __STW VKE, 0
  74. L T 10
  75. __ASSERT== __ACCU 1, 0
  76. // Test LC
  77. __STWRST
  78. L 0
  79. SI T 10
  80. SET
  81. R T 10
  82. U T 10
  83. __ASSERT== __STW VKE, 0
  84. SET
  85. L W#16#1010
  86. SI T 10
  87. U T 10
  88. __ASSERT== __STW VKE, 1
  89. __SLEEP 101
  90. CLR
  91. L W#16#1010
  92. SI T 10
  93. U T 10
  94. __ASSERT== __STW VKE, 0
  95. L T 10
  96. __ASSERT> __ACCU 1, 0
  97. __ASSERT< __ACCU 1, 10
  98. DTB
  99. XOW W#16#1000
  100. __SLEEP 101
  101. LC T 10
  102. __ASSERT== __ACCU 1, __ACCU 2
  103. // Test timer parameter
  104. AUF DB 1
  105. L DBW 0
  106. __ASSERT== __ACCU 1, 24
  107. CALL FB 1, DB 1 (
  108. TIMER_VAR := T 42
  109. )
  110. CALL SFC 46 // STOP CPU
  111. END_ORGANIZATION_BLOCK
  112. FUNCTION_BLOCK FB 1
  113. VAR_INPUT
  114. TIMER_VAR : TIMER;
  115. END_VAR
  116. BEGIN
  117. L DIW 0
  118. __ASSERT== __ACCU 1, 42
  119. L #TIMER_VAR
  120. __ASSERT== __ACCU 1, 0
  121. U #TIMER_VAR
  122. __ASSERT== __STW VKE, 0
  123. SET
  124. L S5T#10s
  125. SI T 42
  126. CLR
  127. U T 42
  128. __ASSERT== __STW VKE, 1
  129. CLR
  130. U #TIMER_VAR
  131. __ASSERT== __STW VKE, 1
  132. L #TIMER_VAR
  133. __ASSERT<> __ACCU 1, 0
  134. SI #TIMER_VAR
  135. END_FUNCTION_BLOCK
  136. DATA_BLOCK DB 1
  137. FB 1
  138. BEGIN
  139. TIMER_VAR := T 24;
  140. END_DATA_BLOCK