summaryrefslogtreecommitdiff
path: root/sim/ucsim/s51.src/test/tim_ser.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /sim/ucsim/s51.src/test/tim_ser.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'sim/ucsim/s51.src/test/tim_ser.c')
-rw-r--r--sim/ucsim/s51.src/test/tim_ser.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/sim/ucsim/s51.src/test/tim_ser.c b/sim/ucsim/s51.src/test/tim_ser.c
new file mode 100644
index 0000000..91d109a
--- /dev/null
+++ b/sim/ucsim/s51.src/test/tim_ser.c
@@ -0,0 +1,73 @@
+#include "hw.h"
+
+#include "serial.h"
+#include "t0.h"
+#include "timer.h"
+#include "print.h"
+
+#define T0H 0xfc
+#define T0L 0x67
+
+unsigned int t0cnt;
+__xdata char *simif;
+
+void t0_it(void) __interrupt (1)
+{
+ TL0= T0L;
+ TH0= T0H;
+ if (t0cnt)
+ t0cnt--;
+}
+
+char min='a', max='z';
+
+void process(void)
+{
+ unsigned char c;
+ c= serial_receive();
+ if ((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z'))
+ {
+ c^= 0x20;
+ min= 'a';
+ max= 'z';
+ P1= 1;
+ }
+ if ((c >= '0') && (c <= '9'))
+ {
+ min= '0';
+ max= '9';
+ P1= 2;
+ }
+ print_c(c);
+}
+
+void main(void)
+{
+ char c= 'a';
+ beallitas();
+
+ t0cnt= T_kezdoertek(1);
+ TL0= t0cnt & 0xff;
+ TH0= t0cnt >> 8;
+ T0idozito1(0);
+ T0beallit(t0cnt);
+ ET0= 1;
+ T0start();
+ EA= 1;
+ print("\nStart\n");
+
+ t0cnt= 10;
+ for (;;)
+ {
+ if (serial_received())
+ process();
+ if (!t0cnt)
+ {
+ print_c(c);
+ if (++c > max)
+ c= min;
+ t0cnt= 10;
+ }
+ }
+}