⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lst

📁 LED汉字显示屏控制电路部分的程序代码。接收来自PC机的串口数据
💻 LST
📖 第 1 页 / 共 3 页
字号:
 287   5                        }
 288   4                        FlagFont=TRUE;
 289   4                        break;
 290   4          case ASCII_NR:if(BufCount2==0)   //换行
 291   4                        {if(FlagFont)
 292   5                         {wr_fm1808(BufAddr2,BFLAGFONT);}
 293   5                         else
 294   5                         {wr_fm1808(BufAddr2,SFLAGFONT);}
 295   5                         BufCount2++;
 296   5                        }
 297   4                        else if(FlagFont)
 298   4                        {while(BufCount2<=30)
 299   5                         {wrbblank();
 300   6                         }
 301   5                         BufAddr2+=50;
 302   5                         BufCount2=0;
 303   5                        }
C51 COMPILER V7.50   MAIN                                                                  09/19/2008 13:23:34 PAGE 6   

 304   4                        else
 305   4                        {while(BufCount2<=48)
 306   5                         {wrsblank();
 307   6                         }
 308   5                         BufAddr2+=50;
 309   5                         BufCount2=0;
 310   5                        }
 311   4                        break;
 312   4          default:if(BufCount2==0)
 313   4                  {if(FlagFont)
 314   5                   {wr_fm1808(BufAddr2,BFLAGFONT);}
 315   5                   else
 316   5                   {wr_fm1808(BufAddr2,SFLAGFONT);}
 317   5                   BufCount2++;
 318   5                  }
 319   4                  half_addr(qm,wm);
 320   4                  wrzikuaddr();
 321   4                  if((FlagFont&&(BufCount2>30))||(!FlagFont&&(BufCount2>48)))
 322   4                  {BufAddr2+=50;
 323   5                   BufCount2=0;
 324   5                  }
 325   4                  break;
 326   4         }
 327   3        }
 328   2        else if((qm<32)||((qm>126)&&(qm<161)))
 329   2        {continue;}
 330   2        else
 331   2        {if(BufCount1--)
 332   3         {wm=rd_fm1808(BufAddr1++);}
 333   3         else break;
 334   3         if((qm>=0xb0&&qm<=0xf7)&&(wm>=0xa0&&wm<=0xfe)) //汉字区位码
 335   3         {if(BufCount2==0)
 336   4          {if(FlagFont)
 337   5           {wr_fm1808(BufAddr2,BFLAGFONT);}
 338   5           else
 339   5           {wr_fm1808(BufAddr2,SFLAGFONT);}
 340   5           BufCount2++;
 341   5          }
 342   4          hanzi_addr(qm,wm);
 343   4          wrzikuaddr();
 344   4          if((FlagFont&&(BufCount2>30))||(!FlagFont&&(BufCount2>48)))
 345   4          {BufAddr2+=50;
 346   5           BufCount2=0;
 347   5          }
 348   4         }
 349   3         else if((qm==0xa1)&&(wm>=0xa1&&wm<=0xfe)) //全角标点01符号
 350   3         {if(BufCount2==0)
 351   4          {if(FlagFont)
 352   5           {wr_fm1808(BufAddr2,BFLAGFONT);}
 353   5           else
 354   5           {wr_fm1808(BufAddr2,SFLAGFONT);}
 355   5           BufCount2++;
 356   5          }
 357   4          full01_addr(qm,wm);
 358   4          wrzikuaddr();
 359   4          if((FlagFont&&(BufCount2>30))||(!FlagFont&&(BufCount2>48)))
 360   4          {BufAddr2+=50;
 361   5           BufCount2=0;
 362   5          }
 363   4         }
 364   3         else if((qm==0xa3)&&(wm>=0xa0&&wm<=0xfe)) //全角标点03符号
 365   3         {if(BufCount2==0)
C51 COMPILER V7.50   MAIN                                                                  09/19/2008 13:23:34 PAGE 7   

 366   4          {if(FlagFont)
 367   5           {wr_fm1808(BufAddr2,BFLAGFONT);}
 368   5           else
 369   5           {wr_fm1808(BufAddr2,SFLAGFONT);}
 370   5           BufCount2++;
 371   5          }
 372   4          full03_addr(qm,wm);
 373   4          wrzikuaddr();
 374   4          if((FlagFont&&(BufCount2>30))||(!FlagFont&&(BufCount2>48)))
 375   4          {BufAddr2+=50;
 376   5           BufCount2=0;
 377   5          }
 378   4         }
 379   3         else continue;
 380   3        }
 381   2       }
 382   1       if(BufCount2!=0)
 383   1       {if(FlagFont)
 384   2        {while(BufCount2<=30)wrbblank();
 385   3        }
 386   2        else
 387   2        {while(BufCount2<=48)wrsblank();
 388   3        }
 389   2        BufAddr2+=50;
 390   2        BufCount2=0;
 391   2       }
 392   1       wr_fm1808(BufAddr2,NFLAGFONT);  //结束标记
 393   1      }
 394          
 395          uchar rdzikudat(void)
 396          {P1=ziku.port.p1;
 397   1       return(XBYTE[ziku.port.p2p0]);
 398   1      }
 399          
 400          void getzikuaddr(void)
 401          {uchar tempb;
 402   1       uint j,tempw;
 403   1       tempw=BufAddr2+BufCount2;
 404   1       tempb=rd_fm1808(tempw);
 405   1       ziku.port.p1=tempb;
 406   1       BufCount2++;
 407   1       tempw=BufAddr2+BufCount2;
 408   1       tempb=rd_fm1808(tempw);
 409   1       j=(uint)tempb;
 410   1       j<<=8;
 411   1       BufCount2++;
 412   1       tempw=BufAddr2+BufCount2;
 413   1       tempb=rd_fm1808(tempw);
 414   1       j+=(uint)tempb;
 415   1       ziku.port.p2p0=j;
 416   1       BufCount2++;
 417   1      }
 418          
 419          void array_addr_dat(void)
 420          {uchar flagfont;
 421   1       uchar i,tempb;
 422   1       uint tempw;
 423   1       uint currentrow;
 424   1       uint currentline;
 425   1       BufAddr2=BUFHEAD2;
 426   1       BufCount2=0;
 427   1       BufAddr3=BUFHEAD3;
C51 COMPILER V7.50   MAIN                                                                  09/19/2008 13:23:34 PAGE 8   

 428   1       while(1)
 429   1       {kmg();
 430   2        tempw=BufAddr2+BufCount2;
 431   2        flagfont=rd_fm1808(tempw);
 432   2        BufCount2++;
 433   2        if(BufAddr3>=BUFHEAD2)
 434   2        {flagfont=NFLAGFONT;}
 435   2        if(flagfont==SFLAGFONT)
 436   2        {for(currentline=0;currentline<32;)
 437   3         {getzikuaddr();
 438   4          currentrow=BufAddr3;
 439   4          for(i=0;i<16;i++)
 440   4          {tempw=currentrow+currentline;
 441   5           tempb=rdzikudat();
 442   5           wr_fm1808(tempw,tempb);
 443   5           ziku.addr+=1;
 444   5           tempb=rdzikudat();
 445   5           tempw=currentrow+currentline+1;
 446   5           wr_fm1808(tempw,tempb);
 447   5           ziku.addr++;
 448   5           currentrow+=32;
 449   5          }
 450   4          currentline+=2;
 451   4         }
 452   3         BufAddr3+=512;
 453   3        }
 454   2        else if(flagfont==BFLAGFONT)
 455   2        {currentrow=BufAddr3;
 456   3         for(i=0;i<24;i++)
 457   3         {wr_fm1808(currentrow,0x00);
 458   4          currentrow+=32;
 459   4         }
 460   3         currentrow=BufAddr3+31;
 461   3         for(i=0;i<24;i++)
 462   3         {wr_fm1808(currentrow,0x00);
 463   4          currentrow+=32;
 464   4         }
 465   3         for(currentline=1;currentline<31;)
 466   3         {getzikuaddr();
 467   4          currentrow=BufAddr3;
 468   4          for(i=0;i<24;i++)
 469   4          {tempw=currentrow+currentline;
 470   5           tempb=rdzikudat();
 471   5           wr_fm1808(tempw,tempb);
 472   5           ziku.addr++;
 473   5           tempb=rdzikudat();
 474   5           tempw=currentrow+currentline+1;
 475   5           wr_fm1808(tempw,tempb);
 476   5           ziku.addr++;
 477   5           tempb=rdzikudat();
 478   5           tempw=currentrow+currentline+2;
 479   5           wr_fm1808(tempw,tempb);
 480   5           ziku.addr++;
 481   5           currentrow+=32;
 482   5          }
 483   4          currentline+=3;
 484   4         }
 485   3         BufAddr3+=768;
 486   3        }
 487   2        else
 488   2        {BufAddr3/=32;
 489   3         tempb=(uchar)BufAddr3;
C51 COMPILER V7.50   MAIN                                                                  09/19/2008 13:23:34 PAGE 9   

 490   3         wr_fm1808(TOTALROWL,tempb);
 491   3         delay(10);
 492   3         BufAddr3>>=8;
 493   3         tempb=(uchar)BufAddr3;
 494   3         wr_fm1808(TOTALROWH,tempb);
 495   3         break;
 496   3        }
 497   2        BufAddr2+=50;
 498   2        BufCount2=0;
 499   2       }
 500   1      }
 501          
 502          void wrstartaddr1(void)
 503          {P1=CE1;
 504   1       XBYTE[STARTROW]=0;
 505   1       P1=CE2;
 506   1       XBYTE[STARTROW]=0;
 507   1       P1=CE3;
 508   1       XBYTE[STARTROW]=0;
 509   1       P1=CE4;
 510   1       XBYTE[STARTROW]=0;
 511   1      }
 512          
 513          void wrstartaddr2(void)
 514          {P1=CE1;
 515   1       XBYTE[STARTROW]=StartRow;
 516   1       P1=CE2;
 517   1       XBYTE[STARTROW]=StartRow;
 518   1       P1=CE3;
 519   1       XBYTE[STARTROW]=StartRow;
 520   1       P1=CE4;
 521   1       XBYTE[STARTROW]=StartRow;
 522   1      }
 523          
 524          void clear_idt7132(void)
 525          {uint tempw;
 526   1       for(tempw=0;tempw<2048;tempw++)
 527   1       {P1=CE1;
 528   2        XBYTE[tempw]=0xff;
 529   2        P1=CE2;
 530   2        XBYTE[tempw]=0xff;
 531   2        P1=CE3;
 532   2        XBYTE[tempw]=0xff;
 533   2        P1=CE4;
 534   2        XBYTE[tempw]=0xff;
 535   2       }
 536   1      }
 537          
 538          void fill16rows(uchar chip,uchar fillrow)
 539          {uchar i,j;
 540   1       uchar tempb;
 541   1       uint  tempw;
 542   1       for(j=0;(j<16)&&(CurrentRow<TotalRow);j++)
 543   1       {for(i=0;i<32;i++)
 544   2        {tempw=CurrentRow*32+i;
 545   3         tempb=rd_fm1808(tempw);
 546   3         tempb=~tempb;
 547   3         tempw=(uint)(fillrow*32+i);
 548   3         P1=chip;
 549   3         XBYTE[tempw]=tempb;
 550   3        }
 551   2        CurrentRow++;
C51 COMPILER V7.50   MAIN                                                                  09/19/2008 13:23:34 PAGE 10  

 552   2        fillrow++;
 553   2       }
 554   1      }
 555          
 556          void fillscreen(void)
 557          {clear_idt7132();
 558   1       CurrentRow=0;
 559   1       fill16rows(CE1,0);
 560   1       if(CurrentRow<TotalRow)
 561   1       fill16rows(CE2,0);
 562   1       if(CurrentRow<TotalRow)
 563   1       fill16rows(CE3,0);
 564   1       if(CurrentRow<TotalRow)
 565   1       fill16rows(CE4,0);
 566   1       wrstartaddr1();
 567   1      }
 568          
 569          
 570          void fillblankrow(uchar chip,uchar fillrow)
 571          {uchar i;
 572   1       uint tempw;
 573   1       for(i=0;i<32;i++)
 574   1       {tempw=(uint)(fillrow*32+i);
 575   2        P1=chip;
 576   2        XBYTE[tempw]=0xff;
 577   2       }
 578   1      }
 579          

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -