16*16点阵程序问题

2019-03-25 19:01发布

pic16f877a芯片用两个74hc595和一个74hc154芯片设计16*16点阵。请问怎样显示汉字啊。 我用74hc154行扫描,显示的汉字乱作一团,不该亮的点都亮了,请问我应该怎样做啊?! 程序如下:#include<pic.h>
#define uint unsigned int
#define uchar unsigned char
__CONFIG(0XFF31);
void delay(uint z);
void out595();
void write595(uint dat);
void display();
void displays(uint timer);
uchar temp[32]; //缓存区
const t0[16]={0xf0,0x70,0xb0,0x30,0xd0,0x50,0x90,0x10,0xe0,0x60,0xa0,0x20,0xc0,0x40,0x80,0x00}; //行扫描   const t1[32]={0x00,0x00,0x00,0x08,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x00,0x00,0x00,0x00};  //汉字“工”   const t2[32]={0x00,0x00,0x7F,0xF8,0x00,0x10,0x00,0x20,0x00,0x40,0x01,0x80,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00}; //汉字“了”
void main()
{  uint m=0,j=0;
  TRISD=0;
    for(j=0;j<32;j++)
       temp[j]=t1[j];
        displays(2);
   
  
   
 for(j=0;j<32;j++)
  temp[j]=t2[j];
  displays(2);
}
  void write595(uint dat)
{       uint i;
  TRISB=0;
   for(i=0;i<8;i++)
 {   RB5=0;
      if((dat&0x01)==0x01)
        RB6=1;
        else
       RB6=0;
  dat>>=1; 
         RB5=1;
 
}
       
  
     
}
void out595()
{
   TRISB=0;
     RB7=0;
     RB7=1; }
void  delay(uint z)
{
 uint i,j;
   for(i=0;i<z;i++)
     for(j=100;j>0;j--); }   void display()
{
    int i,j,k;
            TRISD=0;
         
    for(i=0;i<16;i++)
                    
     {           
        for(j=2;j>0;)
          {  
        PORTD=t0;
       j--;
          write595(temp[i*2+j]);
          out595();
                            delay(2);
          
       }
     }
       
        k=100;
     while(k--);
     
                           }
void displays(uint timer)
{
 unsigned char i; 
 while(timer--)
   {  
  i=110;  
  while(i--)
   display();
 }
} 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。