Debian Codegraph @

t/results/sep_7_1998

raw
1 From [email protected] Tue Jul 7 20:33:03 1998
2 Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
3 id AA32480; Tue, 7 Jul 1998 20:33:03 -0400
4 Received: from wormwood.ee.byu.edu (wormwood.ee.byu.edu [128.187.30.54])
5 by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id TAA30127
6 for <[email protected]>; Tue, 7 Jul 1998 19:48:43 -0400 (EDT)
7 Received: from wormwood (localhost [127.0.0.1]) by wormwood.ee.byu.edu with SMTP (8.7.6/8.7.1) id RAA26916 for <[email protected]>; Tue, 7 Jul 1998 17:48:42 -0600 (MDT)
8 Sender: [email protected]
9 Message-Id: <[email protected]>
10 Date: Tue, 07 Jul 1998 17:48:41 -0600
11 From: "Timothy B. Gold" <[email protected]>
12 X-Mailer: Mozilla 3.04Gold (X11; I; HP-UX B.10.20 9000/780)
13 Mime-Version: 1.0
14 To: [email protected]
15 Subject: Interrupt Handler for Serial communication
16 Content-Type: multipart/mixed; boundary="------------18CC6AC44E2E"
17
18 This is a multi-part message in MIME format.
19
20 --------------18CC6AC44E2E
21 Content-Type: text/plain; charset=us-ascii
22 Content-Transfer-Encoding: 7bit
23
24 Here's a bit of code that will buffer incoming serial information so
25 that no information will be lost when transmitting to the handy board.
26 There are two files: serial_isr.c and serial_isr.asm. You'll need to
27 assemble the .asm file using as11_ic, and then both the .c file and the
28 .icb file need to be loaded onto the handy board. I'm sure improvements
29 could be made to the code to clean it up a little, but it's a start (and
30 I haven't had any problems with it yet). Enjoy!
31
32 --------------18CC6AC44E2E
33 Content-Type: text/plain; charset=us-ascii; name="serial_isr.c"
34 Content-Transfer-Encoding: 7bit
35 Content-Disposition: inline; filename="serial_isr.c"
36
37 /* C program to read serial port with interrupt service routine */
38 /* First version: Written by Anton Wirsch 20 Nov 1997 */
39
40 /*
41
42 Second Version: Written by Tim Gold 27 May 1998
43 BYU Robotics Lab
44 [email protected]
45
46 Really, the only thing left from the original code are a few
47 lines in the .asm file. Everything else I pretty much had to
48 rewrite from scratch to get it to work the way I wanted to.
49 But the orignal code by Anton was a very helpful starting point.
50
51 Needed files: serial_isr.c
52 serial_isr.icb
53 serial_isr.asm (needed to change the buffer size)
54
55 The buffer size here is 32 bytes (probably much larger than it needs
56 to be.) To change the buffer size, do the following:
57 1. Change the BUFFER_SIZE constant below to the
58 desired number of bytes.
59 2. Edit the line(s) in the serial_isr.asm which contain
60 the word "EDIT" in the comment so that the value
61 matches that of BUFFER_SIZE.
62 3. Recreate the serial_isr.icb file by typing the following:
63 > as11_ic serial_isr.asm
64
65 */
66
67
68
69
70 #define BUFFER_SIZE 32 /* change buffer size here -- see above */
71
72 /* various constants used by the program... */
73 #define BAUD 0x102b /* baud rate set to 9600 */
74 #define SCCR2 0x102d
75 #define SCCR1 0x102c
76 #define SCSR 0x102e
77 #define SCDR 0x102f
78
79 int buffer[BUFFER_SIZE]; /* this is the actual buffer */
80
81
82 void initSerial()
83 {
84 /* Call this routine to activate the serial interrupt handler. */
85 int i,temp;
86
87 /* clear out buffer */
88 for(i=0; i<BUFFER_SIZE; i++)
89 buffer[i] = 0;
90
91 /* clear vairous flags */
92 DATA_FLAG = 0;
93 INCOMING = 0;
94 CURRENT = 0;
95
96 /* pass address of buffer to interrupt routine */
97 buffer_ptr = (int) buffer;
98 BASE_ADDR = (int) buffer;
99
100 /* activate interrupt routine */
101 temp = peek(SCCR2);
102 temp |= 0x24;
103 poke(SCCR2, temp);
104 poke(0x3c, 1);
105 }
106
107 void closeSerial()
108 {
109 int temp;
110
111 /* deactivate the interrupt routine */
112 temp = peek(SCCR2);
113 temp &= 0xdf;
114 poke(SCCR2, temp);
115 READ_SERIAL = 0x0000;
116 poke(0x3c, 0);
117
118 }
119
120 void serialPutChar(int c)
121 {
122 /* call this function to write a character to the serial port */
123
124 while (!(peek(0x102e) & 0x80));
125 poke(0x102f, c);
126
127 }
128
129
130 int dataAvailable()
131 {
132 /* This function can be used to check to see if any data is available */
133 return DATA_FLAG;
134 }
135
136
137 int serialGetChar()
138 {
139 /* Create blocking getchar for serial port... */
140 int return_char;
141
142 /* loop until data is available */
143 while(!DATA_FLAG);
144
145 /* get the character to return */
146 return_char = buffer[CURRENT];
147
148 /* check for wrap around... */
149 CURRENT++;
150 if(CURRENT == BUFFER_SIZE)
151 CURRENT = 0;
152 if(CURRENT == INCOMING)
153 DATA_FLAG = 0;
154 return return_char;
155
156 }
157
158
159
160
161
162 --------------18CC6AC44E2E
163 Content-Type: text/plain; charset=us-ascii; name="serial_isr.asm"
164 Content-Transfer-Encoding: 7bit
165 Content-Disposition: inline; filename="serial_isr.asm"
166
167 /* This sets up the serial interrupt service routine */
168 /* First Version: Written by Anton L. Wirsch 20 Nov 1997 */
169 /* Second Version: Written by Tim Gold 27 May 1998
170 BYU Robotics Lab
171 [email protected]
172
173 Really, the only thing left from the original code are a few
174 lines in the .asm file. Everything else I pretty much had to
175 rewrite from scratch to get it to work the way I wanted to.
176 But the orignal code by Anton was a very helpful starting point.
177
178 Needed files: serial_isr.c
179 serial_isr.icb
180 serial_isr.asm (needed to change the buffer size)
181
182 The buffer size here is 32 bytes (probably much larger than it needs
183 to be.) To change the buffer size, do the following:
184 1. Change the BUFFER_SIZE constant in serial_isr.c to the
185 desired number of bytes.
186 2. Edit the line in this fils which contains
187 the word "EDIT" in the comment so that the value
188 matches that of BUFFER_SIZE.
189 3. Recreate the serial_isr.icb file by typing the following:
190 > as11_ic serial_isr.asm
191 */
192
193
194 /* change this line to match your library path... */
195 #include "/usr/local/ic/libs/6811regs.asm"
196
197 ORG MAIN_START
198 variable_CURRENT:
199 FDB 00 * ptr to next data to be read by user
200
201 variable_INCOMING:
202 FDB 00 * number of bytes received (circular count)
203
204 variable_BASE_ADDR:
205 FDB 00 * base address of buffer (to be set by init routine)
206
207 variable_DATA_FLAG:
208 FDB 00 * flag set when data is available
209
210 variable_buffer_ptr:
211 FDB 00 * pointer to CURRENT buffer
212
213 subroutine_initialize_module:
214 /* change this line to match your library path... */
215 #include "/usr/local/ic/libs/ldxibase.asm"
216
217 ldd SCIINT,X
218 std interrupt_code_exit+1
219 ldd #interrupt_code_start
220 std SCIINT,X
221
222 rts
223
224 interrupt_code_start:
225 ldad variable_INCOMING * store INCOMING into AB
226 cmpb #00 * compare B with 0
227 bhi skip * goto "skip" if (B > 0)
228 ldx variable_BASE_ADDR * STORE ADDRESS OF ARRY IN X
229 inx * SKIP THE FIRST (?)
230 inx * TWO BYTES (?)
231 inx * OFFSET TO THE HIGHER BYTE (?)
232 stx variable_buffer_ptr * SAVE PTR VALUE
233 bra cont
234
235 skip:
236 ldx variable_buffer_ptr * load buffer pointer into x
237 cont:
238 ldad variable_INCOMING * load INCOMING into AB
239 incb * increment INCOMING
240 cmpb #32 * compare B and 32 --EDIT TO CHANGE BUFFER SIZE--
241 beq reset_count * if a=32, goto reset_count
242 bra cont1
243 reset_count:
244 ldad #00 * set count to zero
245 cont1:
246 stad variable_INCOMING * store AB into INCOMING
247
248 ldab SCSR * load SCSR (SCI status register) into B (why?)
249 ldab SCDR * load SCSR (SCI data register) into B
250
251 stab ,X * store data in array
252 inx * increment by two bytes
253 inx
254 stx variable_buffer_ptr * save the pointer value
255 ldad #01 * load 1 into AB
256 stad variable_DATA_FLAG * store AB into DATA_FLAG (indicating data is available)
257 interrupt_code_exit:
258 jmp $0000
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 --------------18CC6AC44E2E--
276
277
278