insn_SA.awl 2.1 KB

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