summaryrefslogtreecommitdiff
path: root/support/regression/tests/interrupt.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/regression/tests/interrupt.c')
-rw-r--r--support/regression/tests/interrupt.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/support/regression/tests/interrupt.c b/support/regression/tests/interrupt.c
new file mode 100644
index 0000000..c0d0d32
--- /dev/null
+++ b/support/regression/tests/interrupt.c
@@ -0,0 +1,48 @@
+/** Interrupt tests.
+ regbank: 0,1
+ */
+#include <testfwk.h>
+
+#if defined(__SDCC_mcs51)
+
+#include <8052.h>
+
+volatile long lA = 12345;
+volatile long lB = 67890;
+volatile long lC = 0;
+
+#endif
+
+void
+testInterrupt (void)
+{
+#if defined(__SDCC_mcs51)
+ register long x = lC;
+
+ //enable the interrupt and set it
+ ET2 = 1;
+ EA = 1;
+ TF2 = 1;
+
+ while (TF2)
+ ; //wait until serviced
+ ASSERT (lC + x == 74474);
+#else
+ ASSERT (1);
+#endif
+}
+
+#if defined(__SDCC_mcs51)
+// Timer2 interrupt service routine
+// with register and (stack)spil usage
+void
+T2_isr (void) __interrupt 5 __using({regbank})
+{
+ long a, b, c;
+ a = lA + 0xBABE;
+ b = lB + 0xBEEB;
+ c = a ^ b;
+ lC = c;
+ TF2 = 0;
+}
+#endif