📄 main.lst
字号:
236 2 SEL1=HIGH;SEL0=HIGH; //select ram
237 2 for (j=0;j<16;j++)
238 2 for (i=0;i<2;i++)
239 2 //*(temp_ram_addr+j*2+i)=mat[j][i];
240 2 *(temp_ram_addr+j*2+i)=0x55;
C51 COMPILER V7.06 MAIN 03/06/2006 15:51:31 PAGE 5
241 2 temp_ram_addr=temp_ram_addr+32;
242 2 disp_word_addr=disp_word_addr+2;
243 2 word_counter--;
244 2 }
245 1 SEL1=HIGH;SEL0=HIGH;
246 1 //example();
247 1 temp_ram_addr=0x600;
248 1 disp_word_addr=0x100;
249 1 }
250
251 void init_disp()
252 {
253 1 unsigned char data counter;
254 1
255 1 //for (counter=0;counter<DISP_SIZE;counter++) *(disp_ram_addr+counter)=counter;
256 1 for (counter=0;counter<DISP_SIZE;counter++) *(disp_ram_addr+counter)=0x00;
257 1 for (counter=0;counter<16;counter++) temp[counter]=0x00;
258 1 //for (counter=0;counter<16;counter++) temp[counter]=*(temp_ram_addr+counter*2);
259 1 disp_word=0x00;
260 1 }
261
262 void init_interrupt()
263 {
264 1 /* T0工作在方式2,fosc=36MHz, T=10ms,则TC=65536-10000/(1/3)=35536 (0x8ad0) */
265 1 /* fosc=12MHz,则TC=55536(0xd8f0)*/
266 1 TMOD=TMOD|0x01;//T0工作在方式1
267 1 TH0=0xc1; //定时器T0初值
268 1 TL0=0x80;
269 1 EA=1; //开中断
270 1 ET0=1; //允许T0中断
271 1 TR0=1; //启动T0
272 1 }
273
274 void timer() interrupt 1 using 2 //中断源为1(T0),使用寄存器组2
275 {
276 1 TH0=0xc1; //重装定时器T0初值
277 1 TL0=0x80;
278 1 /*
279 1 if (speed_counter==move_speed) {
280 1 left_move();
281 1 //right_move();
282 1 //up_move();
283 1 //down_move();
284 1 speed_counter=0;
285 1 }
286 1 speed_counter++;*/
287 1 //left_move();
288 1 //speed_counter++;
289 1 disp_ram();
290 1 MAX485=~MAX485;
291 1 }
292
293 void init_cpld()
294 {
295 1 SEL1=HIGH;
296 1 SEL0=HIGH;
297 1 SDA = LOW;
298 1 CPLD_SEL=HIGH;
299 1 wait();
300 1 SDA = HIGH;
301 1 }
302
C51 COMPILER V7.06 MAIN 03/06/2006 15:51:31 PAGE 6
303 void left_move()
304 {
305 1 unsigned char data i,j;
306 1
307 1
308 1 if (temp_counter>=(word_length*16+64))
309 1 temp_counter=0;
310 1
311 1 if ((temp_counter%8)==0) {
312 2 if ((temp_counter%16)==0)
313 2 for (j=0;j<16;j++) temp[j]=*(temp_ram_addr+j*2+temp_counter*2);
314 2 else
315 2 for (j=0;j<16;j++) temp[j]=*(temp_ram_addr+j*2+temp_counter*2-15);
316 2 }
317 1 temp_counter++;
318 1 if (temp_counter>word_length*16)
319 1 for (j=0;j<16;j++) temp[j]=0x00;
320 1 for (j=0;j<16;j++)
321 1 for (i=0;i<7;i++)
322 1 *(disp_ram_addr+j*8+i)=((*(disp_ram_addr+j*8+i)<<1)&0xfe)|((*(disp_ram_addr+j*8+i+1)>>7)&0x01);
323 1 for (j=0;j<16;j++)
324 1 *(disp_ram_addr+7+j*8)=((*(disp_ram_addr+7+j*8)<<1)&0xfe)|((temp[j]>>7)&0x01);
325 1
326 1 for (j=0;j<16;j++) temp[j]=temp[j]<<1;
327 1 }
328
329 void right_move()
330 {/*
331 1 unsigned char data i,j;
332 1
333 1
334 1 if (temp_counter>=(word_length*16+64))
335 1 temp_counter=0;
336 1
337 1 if ((temp_counter%8)==0) {
338 1 if ((temp_counter%16)==0)
339 1 for (j=0;j<16;j++) temp[j]=*(temp_ram_addr+j*2+1+temp_counter*2);
340 1 else
341 1 for (j=0;j<16;j++) temp[j]=*(temp_ram_addr+j*2+temp_counter*2-16);
342 1 }
343 1
344 1 temp_counter++;
345 1 for (j=0;j<16;j++)
346 1 for (i=7;i>0;i--)
347 1 *(disp_ram_addr+j*8+i)=((*(disp_ram_addr+j*8+i)>>1)&0x7f)|((*(disp_ram_addr+j*8+i-1)<<7)&0x80);
348 1 for (j=0;j<16;j++)
349 1 *(disp_ram_addr+j*8)=((*(disp_ram_addr+j*8)>>1)&0x7f)|((temp[j]<<7)&0x80);
350 1
351 1 for (j=0;j<16;j++) temp[j]=temp[j]>>1;*/
352 1 }
353
354 void up_move()
355 {/*
356 1 unsigned char data i,j;
357 1 unsigned char idata ptemp[8];
358 1
359 1 if (temp_counter>=(((word_length-1)/32+1)*32))
360 1 temp_counter=0;
361 1 if (temp_counter==0)
362 1 for (i=0;i<8;i++) ptemp[i]=0x00;
363 1
364 1 temp_counter++;
C51 COMPILER V7.06 MAIN 03/06/2006 15:51:31 PAGE 7
365 1 if ((temp_counter%32)>16)
366 1 for (i=0;i<8;i++) ptemp[i]=0x00;
367 1 else {
368 1 for (i=0;i<8;i++) {
369 1 if ((i%2)==0)
370 1 ptemp[i]=*(temp_ram_addr+i*16+(temp_counter/32-1)*);
371 1 else
372 1 ptemp[i]=*(temp_ram_addr+i*16-15+);
373 1 }
374 1 }
375 1
376 1 for (j=0;j<15;j++)
377 1 for (i=0;i<8;i++)
378 1 *(disp_ram_addr+j*8+i)=*(disp_ram_addr+(j+1)*8+i);
379 1
380 1 for (i=0;i<8;i++)
381 1 *(disp_ram_addr+120+i)=temp[i];
382 1 /*
383 1 if ((i%2)==0)
384 1 *(disp_ram_addr+120+i)=*(temp_ram_addr+i*16);
385 1 else
386 1 *(disp_ram_addr+120+i)=*(temp_ram_addr+(i-1)*16+1);*/
387 1 }
388
389 void down_move()
390 {
391 1
392 1 }
393
394 void disp_static()
395 {
396 1 unsigned char data i,j;
397 1
398 1 for (j=0;j<16;j++)
399 1 for (i=0;i<8;i++)
400 1 if ((i%2)==0)
401 1 *(disp_ram_addr+j*8+i)=*(temp_ram_addr+i*16+j*2);
402 1 else
403 1 *(disp_ram_addr+j*8+i)=*(temp_ram_addr+(i-1)*16+j*2+1);
404 1 }
405
406 void disp_ram()
407 {
408 1 char data scan_counter=0,counter=0;
409 1
410 1 disp_counter=0x00;
411 1 for (scan_counter=0;scan_counter<16;scan_counter++) {
412 2 for (counter=0;counter<8;counter++) {
413 3 wait();
414 3 CPLD_SEL=LOW;
415 3 disp_word=*(disp_ram_addr+counter+scan_counter*8);
416 3 CPLD_SEL= HIGH;
417 3 SCL = LOW;
418 3 SCL = HIGH;
419 3 *write_addr=disp_word;
420 3 //*write_addr=disp_counter;
421 3 //disp_counter++;
422 3 }
423 2 XLAT=LOW;
424 2 BLANK=LOW;
425 2 XLAT=HIGH;
426 2 BLANK=HIGH;
C51 COMPILER V7.06 MAIN 03/06/2006 15:51:31 PAGE 8
427 2 }
428 1 //DATA_SEL=~DATA_SEL;
429 1 /*
430 1 if (speed_counter==0x40) disp_counter=0xff;
431 1 if (speed_counter==0x80) disp_counter=0x55;
432 1 if (speed_counter==0xc0) disp_counter=0xaa;
433 1 if (speed_counter==0x00) disp_counter=0x00;
434 1 if (speed_counter==0x00) disp_counter=disp_counter+1;
435 1 */
436 1 }
437 /*
438 void example()
439 {
440 unsigned char counter;
441
442 counter=0x00;
443 *(temp_ram_addr+counter)=0xa2;
444 counter++;
445 *(temp_ram_addr+counter)=0x03;
446 counter++;
447 *(temp_ram_addr+counter)=0x63;
448 counter++;
449 *(temp_ram_addr+counter)=0x47;
450 counter++;
451 *(temp_ram_addr+counter)=0x22;
452 counter++;
453 *(temp_ram_addr+counter)=0x2e;
454 counter++;
455 *(temp_ram_addr+counter)=0xff;
456 counter++;
457 *(temp_ram_addr+counter)=0xc4;
458 counter++;
459 *(temp_ram_addr+counter)=0x2c;
460 counter++;
461 *(temp_ram_addr+counter)=0x28;
462 counter++;
463 *(temp_ram_addr+counter)=0x24;
464 counter++;
465 *(temp_ram_addr+counter)=0x56;
466 counter++;
467 *(temp_ram_addr+counter)=0x2a;
468 counter++;
469 *(temp_ram_addr+counter)=0xa0;
470 counter++;
471 *(temp_ram_addr+counter)=0x25;
472 counter++;
473 *(temp_ram_addr+counter)=0x50;
474 counter++;
475 *(temp_ram_addr+counter)=0xfe;
476 counter++;
477 *(temp_ram_addr+counter)=0x8c;
478 counter++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -