insn_SS.awl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ORGANIZATION_BLOCK OB 1
  2. BEGIN
  3. // Start timer and let it expire
  4. __STWRST
  5. L 0
  6. SS 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. SS T 10
  14. U T 10
  15. __ASSERT== __STW VKE, 0
  16. L T 10
  17. __ASSERT>= __ACCU 1, 5
  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 before it expires
  24. __STWRST
  25. L 0
  26. SS 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. SS T 10
  34. U T 10
  35. __ASSERT== __STW VKE, 0
  36. L T 10
  37. __ASSERT>= __ACCU 1, 5
  38. CLR
  39. L W#16#0010
  40. SS 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, 1
  48. L T 10
  49. __ASSERT== __ACCU 1, 0
  50. // Start timer and reset VKE after it expired
  51. __STWRST
  52. L 0
  53. SS 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. SS T 10
  61. U T 10
  62. __ASSERT== __STW VKE, 0
  63. __SLEEP 101
  64. U T 10
  65. __ASSERT== __STW VKE, 1
  66. CLR
  67. SS T 10
  68. U T 10
  69. __ASSERT== __STW VKE, 1
  70. __SLEEP 101
  71. U T 10
  72. __ASSERT== __STW VKE, 1
  73. SET
  74. SS T 10
  75. U T 10
  76. __ASSERT== __STW VKE, 1
  77. // Reset signal
  78. __STWRST
  79. L 0
  80. SS T 10
  81. SET
  82. R T 10
  83. U T 10
  84. __ASSERT== __STW VKE, 0
  85. SET
  86. L W#16#0010
  87. SS T 10
  88. U T 10
  89. __ASSERT== __STW VKE, 0
  90. L T 10
  91. __ASSERT>= __ACCU 1, 5
  92. SET
  93. R T 10
  94. U T 10
  95. __ASSERT== __STW VKE, 0
  96. L T 10
  97. __ASSERT== __ACCU 1, 0
  98. __SLEEP 101
  99. U T 10
  100. __ASSERT== __STW VKE, 0
  101. L T 10
  102. __ASSERT== __ACCU 1, 0
  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. SS #TIMER_VAR
  124. END_FUNCTION_BLOCK
  125. DATA_BLOCK DB 1
  126. FB 1
  127. BEGIN
  128. TIMER_VAR := T 24;
  129. END_DATA_BLOCK