Category : Assembly Language Source Code
Archive   : SERIAL51.ZIP
Filename : SERIAL.LST

 
Output of file : SERIAL.LST contained in archive : SERIAL51.ZIP
C51 COMPILER V2.25, SERIAL 08/08/92 05:33:27 PAGE 1


DOS C51 COMPILER V2.25, COMPILATION OF MODULE SERIAL
OBJECT MODULE PLACED IN SERIAL.OBJ
COMPILER INVOKED BY: C51 SERIAL.C LARGE

stmt level source

1 /****************************************************************************/
2 /* */
3 /* MODULE NAME = Serial.c */
4 /* COMPONENT NAME = Serial.c */
5 /* */
6 /* DESCRIPTIVE NAME = Acorn Replacement Keypad Control Program */
7 /* */
8 /* COPYRIGHT = Public Domain */
9 /* */
10 /* Compiler = Franklin C Vers. 2.25 */
11 /* STATUS = Release 1 Version 1 */
12 /* */
13 /* FUNCTIONS = */
14 /* */
15 /* COMPILER OPTIONS = LARGE */
16 /* LINKER OPTIONS = XDATA (1800H) Note: for 8k DS5000 */
17 /* */
18 /* Credits: Derived from SKEL8051.ASM on CCI BBS - Thanks whoever */
19 /* */
20 /* */
21 /* CHANGE ACTIVITY = */
22 /* DATE |LEVEL |PROGRAMMER|DESCRIPTION */
23 /* ----------+---------+----------+--------------------------------------- */
24 /* 08 Aug 92 | 1.0 | T. Sare | First Version */
25 /* | | | */
26 /* */
27 /****************************************************************************/
28 /* Change version number here only */
29 unsigned char *Version_num = " Vers. 1.0 ";
30
31
32 #include /* define DS5000-8051 registers */
33
34
35 #define UCHAR unsigned char
36 #define UINT unsigned int
37 #define ULONG unsigned long
38
39
40
41 #define TRUE 1
42 #define FALSE 0
43 #define ON 1
44 #define OFF 0
45
46 #define MAXQUEUE 16 /* do not expand queue or rollover */
47 #define MODQUEUE 0x0f /* will not work !!! */
48 #define MAXMILLI 1000
49 #define MAXSEC 60
50
51 #define WATCHDOG_ON TA=0xAA;TA=0x55;PCON |= 0x04 /* enable watchdog */
52 #define WATCHDOG_OFF TA=0xAA;TA=0x55;PCON &= 0xFB /* disable watchdog */
53 #define WATCHDOG_RST TA=0xAA;TA=0x55;RWT=1 /* Reset Watch Dog timer */
54
55 #define POWER_FAIL_EN PCON |= 0x08 /* enable Power Fail int */
C51 COMPILER V2.25, SERIAL 08/08/92 05:33:27 PAGE 2

56 #define STOP_MICRO TA=0xAA;TA=0x55;PCON |= 0x02 /* Stop processor */
57
58
59 #define TIMER0_HIGH 0xFC /* Timer 0 is set for 1 mSec */
60 #define TIMER0_LOW 0x66
61
62
63 /* Protos */
64
65 bit receive_c(UCHAR *c);
66 bit send_c(UCHAR c);
67
68 void main(void);
69 void delay(unsigned int delaytime);
70
71 /* Global data */
72
73
74 typedef struct QUEUE
75 {
76 UCHAR head;
77 UCHAR tail;
78 UCHAR Queue[MAXQUEUE];
79 }QUEUE;
80
81 data QUEUE Transmit, Receive;
82 data QUEUE *RX,*TX;
83 data UCHAR i;
84
85
86 /* Global inits */
87
88 data UINT millisec; /* millisec counter for delays */
89 data UCHAR seconds;
90 bit success;
91 bit txgoing; /* user flag for TX routines */
92
93
94
95 /**************************************/
96 /* Timer 0 interrupt service function */
97 /**************************************/
98
99 /* executes once timer 0 overflow */
100 /* maintains high part of usec counter */
101
102 timer0() interrupt 1 using 2
103 { /* Use Register bank 2 */
104 1
105 1 EA = OFF; /* NO INTS */
106 1 millisec++; /* increment on timer overflow */
107 1 if (millisec == MAXMILLI)
108 1 { /* crude clock for timer functions */
109 2 seconds = (seconds + 1) % MAXSEC;
110 2 millisec = 0;
111 2 }
112 1 TL0 = TIMER0_LOW; /* Reload Low byte Timer 0 */
113 1 TH0 = TIMER0_HIGH; /* Reload High byte Timer 0 */
114 1 EA = ON;
115 1 }
116
117 serial() interrupt 4 using 3
C51 COMPILER V2.25, SERIAL 08/08/92 05:33:27 PAGE 3

118 { /* Service the serial ports */
119 1 /* Use Register bank 3 */
120 1
121 1 ES = OFF; /* disable ints */
122 1 if (TI)
123 1 { /* we have outgoing serial data */
124 2 TI = OFF; /* clear it */
125 2 txgoing = OFF; /* send in progress */
126 2 if (TX->head != TX->tail)
127 2 { /* Send next char */
128 3 SBUF = TX->Queue[TX->head];
129 3 TX->head = (++TX->head) & MODQUEUE;
130 3 }
131 2 }
132 1 else
133 1 { /* we have receive char */
134 2 RI = OFF; /* clear receive int bit */
135 2 if ( ( (RX->tail+1) & MODQUEUE) != RX->head)
136 2 {
137 3 RX->Queue[RX->tail] = SBUF; /* get the char */
138 3 RX->tail = (++RX->tail) & MODQUEUE; /* increment tail */
139 3 }
140 2 }
141 1 ES = ON; /* enable ints */
142 1 }
143
144
145 power_fail() interrupt 5 /* Interrupt Vector 0x2B - DS5000 Only */
146 { /* Shut down and lockup */
147 1 WATCHDOG_OFF;
148 1 T1 = ON; /* the light may be on */
149 1 STOP_MICRO; /* Reset the only way to restart!! */
150 1 }
151
152
153
154 void main (void)
155 { /* main program */
156 1
157 1
158 1 UCHAR rcvchar;
159 1
160 1 POWER_FAIL_EN; /* enable Power Fail int */
161 1 WATCHDOG_OFF;
162 1 T1 = 0; /* LED Off */
163 1 /* setup variable data */
164 1 millisec = 0l; /* Clear counter */
165 1 RX = &Receive; /* init queue pointers */
166 1 TX = &Transmit;
167 1 RX->head = RX->tail = 0;
168 1 TX->head = TX->tail = 0;
169 1 txgoing = OFF; /* clear send in progress */
170 1
171 1 SCON = 0xd2; /* SCON */ /* setup serial port = Mode 3 */
172 1 TMOD = 0x20; /* TMOD */ /* hardware (1200 BAUD @11.059 MHz) */
173 1 TH1 = 0xe8; /* TH1 */ /* Timer 1 Baud Rate Value */
174 1 TR1 = ON; /* enable timer */
175 1 ES = ON; /* enable serial interrupt */
176 1
177 1 /* setup timer 0 interrupt */
178 1 TMOD = TMOD | 0x01; /* select mode 1 */
179 1 TL0 = TIMER0_LOW; /* Set Low byte Timer 0 */
C51 COMPILER V2.25, SERIAL 08/08/92 05:33:27 PAGE 4

180 1 TH0 = TIMER0_HIGH; /* Set high byte Timer 0 for 1 msec */
181 1 ET0 = ON; /* enable timer 0 interrupt */
182 1
183 1 PS = ON; /* serial is highest priority */
184 1 EA = ON; /* global interrupt enable */
185 1 TR0 = ON; /* Start Timer 0 */
186 1
187 1 /* Start of main program loop */
188 1
189 1 while (TRUE)
190 1 {
191 2 WATCHDOG_RST; /* reset it. This line must come before */
192 2 /* WATCHDOG_ON; /* start watchdog. Enable after code is working!*/
193 2
194 2 T1 = ~T1; /* strobe led on T1 */
195 2
196 2 while ( !receive_c(&rcvchar) )
197 2 {
198 3 WATCHDOG_RST; /* whip the dog */
199 3 } /* endwhile */
200 2
201 2 /* do useful work hear */
202 2
203 2 send_c(rcvchar);
204 2 } /* endwhile */
205 1
206 1
207 1
208 1 } /* end main */
209
210 bit send_c(UCHAR c)
211 { /* send a byte */
212 1
213 1 ES = OFF; /* disable ints */
214 1 success = FALSE;
215 1 if ( (TX->head != TX->tail) || txgoing )
216 1 { /* add to queue */
217 2 if ( ((TX->tail+1) & MODQUEUE) != TX->head)
218 2 { /* we got room to add */
219 3 TX->Queue[TX->tail] = c;
220 3 TX->tail = (TX->tail+1) & MODQUEUE;
221 3 success = TRUE;
222 3 }
223 2 }
224 1 else
225 1 {
226 2 SBUF = c;
227 2 txgoing = ON;
228 2 success = TRUE;
229 2 }
230 1 ES = ON; /* enable ints */
231 1 return (success);
232 1 }
233
234 bit receive_c(UCHAR *c)
235 { /* get a char off the queue */
236 1
237 1 success = FALSE;
238 1 if ( RX->head != RX->tail)
239 1 { /* we got a char on queue */
240 2 ES = OFF; /* disable ints */
241 2 *c = RX->Queue[RX->head];
C51 COMPILER V2.25, SERIAL 08/08/92 05:33:27 PAGE 5

242 2 RX->head = (++RX->head) & MODQUEUE;
243 2 ES = ON;
244 2 success = TRUE;
245 2 }
246 1 return(success);
247 1
248 1 }
249
250
251
252 void delay(unsigned int delaytime)
253 { /* delay is in milliseconds, max delay is 65000 msec or 65 sec. */
254 1
255 1 data UINT alarm;
256 1
257 1 alarm = (millisec + delaytime) % MAXMILLI;
258 1 if (alarm < millisec)
259 1 { /* we had rollover */
260 2 while (alarm < millisec)
261 2 {
262 3 WATCHDOG_RST;
263 3 continue;
264 3 }
265 2 }
266 1 else
267 1 { /* normal mode */
268 2 while ( alarm > millisec)
269 2 {
270 3 WATCHDOG_RST;
271 3 continue;
272 3 }
273 2 }
274 1
275 1 } /* end delay */
276

C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)


  3 Responses to “Category : Assembly Language Source Code
Archive   : SERIAL51.ZIP
Filename : SERIAL.LST

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/