打印
[AVR单片机]

程序求解,这个程序某些部分不是很理解,希望程序高手帮忙解

[复制链接]
1733|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
GH013|  楼主 | 2008-10-17 17:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
问题: 

BUFF[12]装入tab[]的数据为什么要相隔32,这个32也好理解一个汉字转换过来就是32个数据,载入下一个汉字也正好是tab[32]开始,,但从里面的程序来看,一个汉字的32个数据我只看见BUFF[]去载入它的前两个数据,其余的30个数据是怎么送出去显示的呢?  


这是一个LED点阵显示屏,可同时显示四个字,并实现按象素点左移 
,其中某些和硬件相关的语句暂可以不去管它,只想知道上面问题的答案,这个程序是51的我准备用AVR来控制…… 

字模:横向取模,高位在左 



#include <AT89x52.H> 
#include <regx52.h> 
#define uchar unsigned char 
#define uint unsigned int 

#define SPEED 1                       //定义速度 
#define light 3                        //定义亮度 

uchar col,disrow;                      //col为位移变量,disrow为行变量 
uint word; 
uchar code tab[]; 
uchar BUFF[12]; 

void loadoneline(void); 
void sendoneline(void); 



/****************************主函数***************************/ 
void main(void) 

  uchar i; 
  col=0;word=0; 
    while(1) 
     { 
        while(col<16)// 循环16次,点亮并移动一个汉字 
        { 
                for(i=0;i<SPEED;i++)//汉字在屏幕上的停留时间(即移动速度快慢) 
                { 
                        for(disrow=0;disrow<16;disrow++)//扫描16行                          
                        { 
                        loadoneline();//装载一线点阵数据 
                        sendoneline();//发送一线点阵数据   

                     
                        P2=(0x10+disrow)^0x60;// 点亮屏幕 
                        P2=(0x20+disrow)^0x60;  
                               
                          
                         P2_5= 1;   // 点亮屏幕                           
                                                
                         P3_1=1;      //(CLK=P3_1)上升沿595输出  

                       
                        } 
                } 
        col++;        //列指针递增 
         } 
     col=0; 
     word=word+32;// 一个汉字移动后,指向下一个汉字 
     if(word>=1024) 
     word=0;// 移动28个汉字后,重新开始 
     } 


/**************装载一线点阵数据****************/ 
void loadoneline(void) 

uchar s; 
        for(s=0;s<5;s++)              //s为要显示的数字+1 
        { 
         
        BUFF[2*s]=tab[word+1+32*s+2*disrow];//~ 
        BUFF[2*s+1]=tab[word+32*s+2*disrow];//~ 
        } 

/***************发送一线点阵数据*******************/ 
void sendoneline(void) 

      char s;  uchar inc; 
      if(col<8) 
         inc=0; 
      else  
         inc=1; 
          for(s=0+inc;s<=7+inc;s++)          
            { 
             SBUF=two_onebyte(BUFF,BUFF[s+1]); 
             while(!TI); 
              TI=0; 
            } 





/*******根据列指针,由双字节合并为单字节的子程序模块12MHZ************/ 
uchar two_onebyte(uchar h1,uchar h2) 

  uchar temp,tempcol; 
    if(col<8)  
      tempcol=col; 
    else 
      tempcol=col-8; 

      temp=(h1>>tempcol)|(h2<<(8-tempcol)); 
      temp=255-temp;//用来取反,由屏的是共阳是共阴决定 
      return temp; 



/***********************汉字点阵码*************************/ 
uchar code tab[]= 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 

//============================================================================= 

/*--  同  --  **  宋体, 12  *32个数据*/ 

0x00,0x00, 
0x3F,0xFE, 
0x20,0x02, 
0x20,0x02, 
0x2F,0xFA, 
0x20,0x02, 
0x20,0x02, 
0x27,0xF2, 
0x24,0x12, 
0x24,0x12, 
0x24,0x12, 
0x27,0xF2, 
0x24,0x12, 
0x20,0x02, 
0x28,0x02, 
0x10,0x02, 
/*--  济  --  **  宋体, 12  **/ 

0x01,0x02,0x02,0x04,0x7F,0xE4,0x08,0x80,0x05,0x11,0x02,0x12,0x0D,0x8A,0x70,0x68, 
0x08,0x88,0x08,0x84,0x08,0x87,0x08,0x84,0x08,0x44,0x08,0x44,0x08,0x24,0x08,0x14, 
/*--  物  --  **  宋体, 12  **/ 

0x01,0x08,0x01,0x08,0x01,0x0A,0x3F,0x8A,0x2A,0xBE,0x2A,0x4A,0x29,0x29,0x29,0x28, 
0x24,0x98,0x24,0x4C,0x22,0x2B,0x21,0x08,0x20,0x88,0x20,0x48,0x14,0x28,0x08,0x00, 
/*--  业  --  **  宋体, 12  **/ 

0x02,0x20,0x02,0x20,0x02,0x20,0x22,0x20,0x62,0x22,0x32,0x24,0x12,0x24,0x0A,0x28, 
0x0A,0x38,0x06,0x28,0x02,0x20,0x02,0x20,0x22,0x20,0x7F,0xFF,0x00,0x00,0x00,0x00, 
/*--  质  --  **  宋体, 12  **/ 

0x3E,0x00,0x01,0xFC,0x01,0x04,0x1F,0xF4,0x01,0x04,0x00,0x84,0x0F,0xE4,0x08,0x24, 
0x09,0x24,0x09,0x24,0x09,0x24,0x09,0x24,0x02,0x84,0x0C,0x42,0x18,0x22,0x08,0x11, 
/*--  量  --  **  宋体, 12  **/ 

0x0F,0xF8,0x08,0x08,0x0F,0xF8,0x08,0x08,0x0F,0xF8,0x00,0x00,0x7F,0xFF,0x08,0x88, 
0x0F,0xF8,0x08,0x88,0x0F,0xF8,0x00,0x80,0x1F,0xF8,0x00,0x80,0x7F,0xFF,0x00,0x00, 
/*--  方  --  **  宋体, 12  **/ 

0x00,0x40,0x00,0x80,0x01,0x00,0x7F,0xFF,0x00,0x40,0x00,0x40,0x0F,0xC0,0x08,0x40, 
0x08,0x20,0x08,0x20,0x08,0x10,0x08,0x10,0x08,0x08,0x09,0x04,0x06,0x03,0x00,0x00, 
/*--  针  --  **  宋体, 12  **/ 

0x04,0x08,0x04,0x08,0x04,0x04,0x04,0x7C,0x04,0x02,0x04,0x3E,0x7F,0x89,0x04,0x08, 
0x04,0x7F,0x04,0x08,0x04,0x08,0x04,0x48,0x04,0x28,0x04,0x18,0x04,0x08,0x04,0x00, 
/*--  :  --  **  宋体, 12  **/ 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00, 


//*规范服务**/ 
/*--  规  --  **  宋体, 12  **/ 

0x00,0x08,0x3F,0x88,0x20,0x88,0x24,0xBE,0x24,0x88,0x24,0x88,0x24,0x88,0x24,0xFF, 
0x24,0x88,0x0A,0x14,0x0A,0x24,0x49,0x64,0x49,0x22,0x48,0x82,0x70,0x41,0x00,0x20, 
/*--  范  --  **  宋体, 12  **/ 

0x04,0x20,0x04,0x20,0x7F,0xFF,0x06,0x20,0x00,0x02,0x1F,0x8C,0x10,0x89,0x10,0x86, 
0x10,0x92,0x1C,0x90,0x08,0x88,0x00,0x87,0x20,0x84,0x20,0x84,0x3F,0x04,0x00,0x04, 
/*--  服  --  **  宋体, 12  **/ 

0x3F,0x3C,0x21,0x24,0x21,0x24,0x29,0x24,0x11,0x3C,0x01,0x24,0x3F,0x24,0x23,0x3C, 
0x23,0x24,0x15,0x24,0x15,0x24,0x09,0x24,0x15,0x22,0x73,0x2A,0x21,0x11,0x00,0x00, 
/*--  务  --  **  宋体, 12  **/ 

0x00,0x20,0x0F,0xE0,0x08,0x30,0x04,0x28,0x02,0x46,0x01,0x81,0x06,0x60,0x78,0x98, 
0x20,0x86,0x0F,0xF8,0x08,0x40,0x08,0x40,0x08,0x20,0x08,0x10,0x0A,0x0C,0x04,0x03, 
/*--  空格  --  **  宋体, 12  **/ 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
//*有呼必应**/ 
/*--  有  --  **  宋体, 12  **/ 

0x00,0x80,0x00,0x80,0x7F,0xFE,0x00,0x40,0x00,0x20,0x0F,0xF0,0x08,0x18,0x08,0x14, 
0x0F,0xF2,0x08,0x11,0x08,0x10,0x0F,0xF0,0x08,0x10,0x09,0x10,0x0E,0x10,0x04,0x10, 
/*--  呼  --  **  宋体, 12  **/ 

0x00,0x00,0x3C,0x00,0x03,0xFF,0x12,0x11,0x32,0x51,0x12,0x91,0x0A,0x91,0x02,0x11, 
0x7F,0xF1,0x02,0x1F,0x02,0x11,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x80,0x01,0x00, 
/*--  必  --  **  宋体, 12  **/ 

0x00,0x20,0x08,0x40,0x19,0x80,0x08,0x80,0x04,0x30,0x04,0x10,0x0A,0x14,0x12,0x14, 
0x21,0x14,0x60,0x92,0x20,0x52,0x10,0x30,0x10,0x18,0x1F,0xF4,0x00,0x03,0x00,0x00, 
/*--  应  --  **  宋体, 12  **/ 

0x00,0x80,0x01,0x00,0x3F,0xFC,0x00,0x04,0x00,0x44,0x10,0x84,0x31,0x0C,0x13,0x14, 
0x09,0x24,0x09,0x24,0x04,0x64,0x04,0x22,0x02,0x02,0x7F,0xFA,0x00,0x01,0x00,0x00, 
/*--  空格  --  **  宋体, 12  **/ 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
//*风格亲和**/ 
/*--  风  --  **  宋体, 12  **/ 

0x00,0x00,0x1F,0xF8,0x10,0x08,0x12,0x08,0x16,0x28,0x12,0x48,0x12,0x88,0x11,0x08, 
0x11,0x08,0x12,0x88,0x56,0x48,0x54,0x24,0x64,0x14,0x60,0x02,0x40,0x01,0x00,0x00, 
/*--  格  --  **  宋体, 12  **/ 

0x01,0x08,0x01,0x08,0x1F,0x88,0x10,0xBF,0x09,0x48,0x0A,0x2C,0x04,0x1C,0x1B,0x2A, 
0x60,0xEA,0x1F,0x89,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x1F,0x88,0x10,0x88, 
/*--  亲  --  **  宋体, 12  **/ 

0x00,0x40,0x00,0x80,0x3F,0xFC,0x04,0x10,0x0C,0x20,0x02,0x20,0x7F,0xFE,0x00,0x80, 
0x00,0x80,0x3F,0xFC,0x00,0x80,0x04,0x88,0x18,0x98,0x30,0x84,0x10,0xA2,0x00,0x40, 
/*--  和  --  **  宋体, 12  **/ 

0x00,0x00,0x00,0xE0,0x00,0x1E,0x3E,0x10,0x22,0x10,0x22,0xFE,0x22,0x10,0x22,0x18, 
0x22,0x38,0x22,0x54,0x22,0xD4,0x22,0x52,0x3E,0x11,0x22,0x10,0x00,0x10,0x00,0x10, 
/*--  空格  --  **  宋体, 12  **/ 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
//**讲究诚信**/ 
/*--  讲  --  **  宋体, 12  **/ 

0x08,0x82,0x08,0x84,0x08,0x8C,0x08,0x84,0x3F,0xE0,0x08,0x80,0x08,0x87,0x08,0x84, 
0x7F,0xF4,0x08,0x84,0x08,0x84,0x08,0x84,0x08,0x54,0x08,0x4C,0x08,0x24,0x08,0x10, 
/*--  究  --  **  宋体, 12  **/ 

0x00,0x40,0x00,0x80,0x7F,0xFE,0x20,0x02,0x04,0x48,0x08,0x44,0x10,0x42,0x03,0xF8, 
0x02,0x40,0x02,0x40,0x02,0x20,0x42,0x20,0x42,0x10,0x42,0x08,0x7C,0x04,0x00,0x00, 
/*--  诚  --  **  宋体, 12  **/ 

0x04,0x02,0x14,0x0C,0x24,0x04,0x7F,0xF0,0x04,0x20,0x04,0x27,0x24,0x24,0x65,0xE4, 
0x29,0x24,0x29,0x24,0x19,0x24,0x49,0x34,0x55,0x2C,0x63,0x54,0x40,0x90,0x00,0x08, 
/*--  信  --  **  宋体, 12  **/ 

0x01,0x10,0x06,0x30,0x02,0x18,0x7F,0xE8,0x00,0x0C,0x1F,0xCC,0x00,0x0A,0x1F,0xC9, 
0x00,0x08,0x1F,0xC8,0x10,0x48,0x10,0x48,0x10,0x48,0x1F,0xC8,0x10,0x48,0x00,0x00, 






//============================================================================ 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 


};

相关帖子

沙发
老狼迈克| | 2008-10-23 13:47 | 只看该作者

每看你程序,只看了你问题

有的时候,一个数组故意多搞些无用数据,是为了别的方面的方便,比如为了兼容,以防止单元数据增大改程序,比如本来一个元素是8位,现在要使用16位的元素等等。


还有的时候,是由于程序的原因方便换算等等。

我说的比较笼统,你将就着看吧

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

11

主题

14

帖子

0

粉丝