summaryrefslogtreecommitdiff
path: root/sim/ucsim/s51.src/test/t0.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/t0.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/t0.c')
-rw-r--r--sim/ucsim/s51.src/test/t0.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/sim/ucsim/s51.src/test/t0.c b/sim/ucsim/s51.src/test/t0.c
new file mode 100644
index 0000000..bb8c42b
--- /dev/null
+++ b/sim/ucsim/s51.src/test/t0.c
@@ -0,0 +1,89 @@
+/*
+ t0.c
+ Segedlet a T0 idozito/szamlalo kezelesehez
+ (c) Drotos Daniel, 2005
+*/
+
+#include "hw.h"
+#include <stdio.h>
+
+#include "timer.h"
+#include "t0.h"
+
+
+
+/* Adott idoziteshez szukseges szamlalo kezdoerteket szamolja ki.
+ A parametert msec-ben kell megadni (kb 0.02-71 kozott) */
+
+unsigned int T0kezdoertek(float ido /* msec */)
+{
+ return T_kezdoertek(ido);
+}
+
+
+/* Idozito uzemmod */
+
+void T0idozito1(bool kapuzott)
+{
+ TR0= 0;
+ TMOD&= 0xf0;
+ TMOD|= 0x01;
+ if (kapuzott)
+ TMOD|= 0x08;
+}
+
+
+/* Szamlalo uzemmod */
+
+void T0szamlalo(bool kapuzott)
+{
+ TR0= 0;
+ TMOD&= 0xf0;
+ TMOD|= 0x01;
+ TMOD|= 0x04;
+ if (kapuzott)
+ TMOD|= 0x08;
+}
+
+
+/* Szamlalo ertek beallitasa */
+
+void T0beallit(unsigned int kezdoertek)
+{
+ TH0= kezdoertek >> 8;
+ TL0= kezdoertek & 0xff;
+}
+
+
+/* Szamlalo ertek beallitasa */
+
+void T0ujratolt(unsigned int kezdoertek)
+{
+ TH0= kezdoertek >> 8;
+ TL0= kezdoertek & 0xff;
+}
+
+
+/* A szamlalo aktualis allapota usec-ben */
+
+float T0eltelt_us(void)
+{
+ unsigned char h, l;
+ h= TH0;
+ l= TL0;
+ return (12.0/Fosc) * ((unsigned int)(h*256+l));
+}
+
+
+/* A szamlalo tulcsordulasaig hatralevo ido usec-ben */
+
+float T0hatravan_us(void)
+{
+ unsigned char h, l;
+ h= TH0;
+ l= TL0;
+ return (12.0/Fosc) * (0x10000 - (unsigned int)(h*256+l));
+}
+
+
+/* End of t0.c */