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

📄 main.lst

📁 条屏控制器的设计的主程序,本例是控制4字,改动几个边界值即可控制任意长个汉字,保证可以实际应用
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.06   MAIN                                                                  03/06/2006 15:51:31 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

*** WARNING C500 IN LINE 1 OF MAIN.C: MISSING DEVICE (SECURITY KEY NOT FOUND)
   1          /******************************************************************************************/
   2          /*                                                                                        */  
   3          /*                      Controller  Program  V1.4(四字)                                   */
   4          /*                                                                                        */
   5          /*      P3.4、P3.3: 11-RAM, 01-FLASH, 10-245_E, 00-REST                                                                           */
   6          /*      RAM:32K  FLASH:512K  CPU_RAM:4K                                                                                                           */
   7          /*      ADDR:   RAM-0x0000~0x7fff   FLASH- (0x0000~0xffff)*8: P1.2、P1.1、P1.0                         */
   8          /*      P1.3:XLAT  P1.4:BLANK  P3.5:CPLD_SEL P1.7:Data_sel              P1.5、P1.6:     on standby                */
   9          /*  P3.2:MAX485_con                                                                       */
  10          /*  Baud:4800pbs                                                                          */
  11          /*                                                                                        */
  12          /*                                                                                        */
  13          /******************************************************************************************/
  14          #pragma small 
  15          
  16          #include <reg52.h>
  17          
  18          #define DISP_SIZE       128     //the length of disp_ram:16*2*4
  19          #define HIGH            1
  20          #define LOW                     0
  21          
  22          void init_sys();
  23          void init_ram();
  24          void init_serial_port();
  25          void init_disp();
  26          void get_disp_word();
  27          void get_zimo();
  28          void init_cpld();
  29          void left_move();
  30          void right_move();
  31          void up_move();
  32          void down_move();
  33          void disp_static();
  34          void disp_ram();
  35          void init_interrupt();
  36          void timer();
  37          //void example();
  38          void wait();
  39                
  40          sbit CPLD_SEL = 0xb5;
  41          sbit DATA_SEL = 0x97;
  42          sbit XLAT         =     0x93;
  43          sbit BLANK        = 0x94;
  44          sbit MAX485   = 0xb2;
  45          sbit SDA          =     0x95;
  46          sbit SCL          = 0x96;
  47          sbit SEL1         = 0xb4;
  48          sbit SEL0         = 0xb3;
  49          sbit FLASH2   = 0x92;
  50          sbit FLASH1   = 0x91;
  51          sbit FLASH0   = 0x90;
  52          
  53          unsigned char xdata * disp_ram_addr;    //disp_ram addr
  54          unsigned char xdata * temp_ram_addr;    //zimo addr
C51 COMPILER V7.06   MAIN                                                                  03/06/2006 15:51:31 PAGE 2   

  55          unsigned char xdata * hzk_addr;                 //hzk addr
  56          unsigned char xdata * asczk_addr;               //ascii addr
  57          unsigned char xdata * disp_word_addr;   //disp_word addr
  58          unsigned char xdata * disp_word_length; //disp_word_length
  59          unsigned char xdata * word_length_addr; //word_length_addr
  60          
  61          unsigned char data      control_word;           //board control word
  62          unsigned int data       word_length;                    //disp_word_length
  63          unsigned long data      temp_counter;        //shift counter
  64          unsigned char pdata     temp[16];                       //one row data
  65          unsigned char data  move_speed;                 //disp speed
  66          unsigned char data      speed_counter;          //speed counter
  67          
  68          unsigned char data      disp_word;              //disp word per scan
  69          unsigned char xdata * write_addr;               //cpld data addr        
  70          unsigned char xdata * read_addr;                //245_e controller data addr
  71          //unsigned int data count;                              //interrupt counter
  72          unsigned char data disp_counter;
  73          
  74          main()
  75          {
  76   1       init_sys();
  77   1       init_ram();
  78   1       init_serial_port();
  79   1       get_disp_word();
  80   1       get_zimo();
  81   1       init_disp();
  82   1       //disp_static();
  83   1       init_cpld();
  84   1       //init_interrupt();
  85   1       while (1) {
  86   2              CPLD_SEL=LOW;
  87   2              BLANK=LOW;
  88   2              if (speed_counter==move_speed) {
  89   3                      left_move();
  90   3                      //right_move();
  91   3                      //up_move();
  92   3                      //down_move();
  93   3              speed_counter=0;
  94   3          }
  95   2          speed_counter++;    
  96   2              disp_ram();
  97   2              MAX485=~MAX485;
  98   2              }
  99   1      }
 100          
 101          void init_sys()
 102          { 
 103   1       
 104   1       //following is init of system
 105   1       CPLD_SEL = LOW;                        //CPLD is not be selected
 106   1       DATA_SEL = HIGH;           //RED DATA is be selected
 107   1       XLAT     = LOW;           //Latch 
 108   1       BLANK    = LOW;           //OE no valid
 109   1       MAX485   = HIGH;           //RS485 is set to transmit
 110   1       SDA      = LOW;                        //I2C data is 0
 111   1       SCL      = LOW;            //I2C scl
 112   1       SEL1     = HIGH;
 113   1       SEL0     = HIGH;           //RAM_CE is be selected 
 114   1       FLASH2   = LOW;        
 115   1       FLASH1   = LOW;
 116   1       FLASH0   = LOW;            //FLASH_0 is be selected 
C51 COMPILER V7.06   MAIN                                                                  03/06/2006 15:51:31 PAGE 3   

 117   1       
 118   1       //following is setup of address
 119   1       hzk_addr               = 0x100;        //hzk addr pointer              FLASH2、FLASH1、FLASH0= 0 0 0
 120   1       asczk_addr             = 0x100;        //asczk addr pointer    FLASH2、FLASH1、FLASH0= 1 1 0
 121   1       disp_word_addr = 0x100;        //disp_word pointer             FLASH2、FLASH1、FLASH0= 1 1 1
 122   1      
 123   1       disp_ram_addr  = 0x100;        //disp_ram_addr_pointer,length=0x400                                    RAM
 124   1       temp_ram_addr  = 0x600;        //swap_ram_addr_pointer,length=disp_word_length * 32    RAM
 125   1       write_addr             = 0x580;        //write cpld_data address                                                               CPLD
 126   1       read_addr              = 0x581;        //read 245_e control_word address                                               245_E
 127   1      
 128   1       word_length_addr =0x80;        //                                                                                                              RAM     
 129   1       
 130   1       //followinf is init of variable
 131   1      
 132   1       word_length    = 0;
 133   1       temp_counter   = 0;
 134   1       move_speed             = 1;
 135   1       speed_counter  = 0;    
 136   1       control_word   = 0x00;
 137   1       disp_counter   = 0x00;
 138   1      }
 139          
 140          void init_ram()
 141          {
 142   1       unsigned char xdata * addr;
 143   1       unsigned int counter; 
 144   1      
 145   1       addr = 0x00;
 146   1       for (counter=0;counter<0x8000;counter++) {
 147   2           *(addr+counter)=0x00;
 148   2           }
 149   1      }
 150          
 151          void init_serial_port()
 152          {
 153   1       //following is init of serial_port
 154   1      
 155   1       TMOD = 0x20;           //定时器T1工作在方式2
 156   1       TL1  = 0xf3;           //初值为0xf3                    波特率为14400
 157   1       TH1  = 0xf3;           //初值为0xf3                    波特率为14400
 158   1       SCON=0x50;                                     //serial port control register
 159   1       /*  SM0 SM1-> 0 1 :方式1    SM2->0:单机对单机 REN->1:允许接收
 160   1               TB8->0:不发送数据第9位  RB8->1:不接收数据第9位 TI->0:发送中断标志复位 RI->1:接收中断标志复位*/
 161   1      
 162   1       PCON = 0x80;           //传输速率加倍 
 163   1       TR1  = HIGH;           //启动T1                                                
 164   1       ES=LOW;
 165   1       EA=LOW;
 166   1      }
 167          
 168          void get_disp_word()
 169          {
 170   1       unsigned int data counter=0;
 171   1       
 172   1       disp_word=0xff;
 173   1       SEL1=HIGH;
 174   1       SEL0=LOW;
 175   1       FLASH2=HIGH;
 176   1       FLASH1=HIGH;
 177   1       FLASH0=HIGH;
 178   1       for (counter=0;counter<0xff;counter++){
C51 COMPILER V7.06   MAIN                                                                  03/06/2006 15:51:31 PAGE 4   

 179   2              control_word= *(read_addr);
 180   2              wait();
 181   2              }
 182   1       SEL1=LOW;
 183   1       SEL0=HIGH;
 184   1       if ((control_word&0x80)==0x80) {
 185   2              while (disp_word!=0x00) {
 186   3                      while (RI == 0);
 187   3                      RI=0;
 188   3                  disp_word=SBUF;
 189   3                      *(disp_word_addr+word_length)=disp_word;
 190   3                      word_length++;
 191   3                      }
 192   2              SBUF=0x55;
 193   2              while (!TI);
 194   2              TI=0;
 195   2              word_length--;
 196   2              word_length=word_length/2;
 197   2          *(word_length_addr)   = word_length%256;
 198   2          *(word_length_addr+1) = word_length/256;
 199   2         }
 200   1        else
 201   1              {
 202   2              word_length=*(word_length_addr+1)*256+*(word_length_addr);
 203   2              }
 204   1      }
 205          
 206          void get_zimo()
 207          {
 208   1       unsigned char data mat[16][2];                         //one chinese word zimo   
 209   1       unsigned char data qu_ma=0x00,wei_ma=0x00,i=0x00,j=0x00;
 210   1       unsigned char data flash_bit=0;        //FLASH select
 211   1       unsigned long data seek=0x00;
 212   1       unsigned int data word_counter=0;
 213   1       
 214   1       for (j=0;j<16;j++)
 215   1              for (i=0;i<2;i++)
 216   1                      mat[j][i]=0x00;
 217   1       word_length=4;
 218   1       word_counter=word_length; 
 219   1       while (word_counter>0) {
 220   2              SEL1=LOW;SEL0=HIGH;                                             //select flash
 221   2              FLASH2=HIGH;FLASH1=HIGH;FLASH0=HIGH;    //chinese word address
 222   2              qu_ma=*(disp_word_addr)-0xa0;
 223   2              wei_ma=*(disp_word_addr+1)-0xa0;
 224   2              seek=94*(qu_ma-1)+(wei_ma-1)*32;
 225   2       
 226   2              flash_bit=(seek+0x100)/0x10000;
 227   2              FLASH2=flash_bit&0x04;
 228   2              FLASH1=flash_bit&0x02;
 229   2              FLASH0=flash_bit&0x01;
 230   2      
 231   2              hzk_addr=seek+0x100-((seek+0x100)/0x10000)*0x10000;
 232   2              for (j=0;j<16;j++)
 233   2                      for (i=0;i<2;i++)
 234   2                              mat[j][i]=*(hzk_addr+j*2+i);
 235   2       

⌨️ 快捷键说明

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