首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

LCD T6963的程序小问题 高手请指教

LCD T6963的程序小问题 高手请指教

调试时 状态检测函数caddr(void)有问题 造成不断查询状态,出不来,我对T6963指令不熟 望懂得人指教啊
#include "system.h"
#include "altera_avalon_pio_regs.h"
#include "alt_types.h"



/*****************************************************************************/
/* lcd???                                                                 */
/*****************************************************************************/
//????S1,S0???????????????
unsigned char caddr(void)
{unsigned char result;
IOWR(LCD_DB_BASE,1,1);
IOWR(LCD_CD_BASE,0,1);
IOWR(LCD_CS_BASE,0,0);
IOWR(LCD_WR_BASE,0,1);
IOWR(LCD_RD_BASE,0,0);
result=IORD(LCD_DB_BASE,0);
IOWR(LCD_RD_BASE,0,1);
IOWR(LCD_CS_BASE,0,1);
return result;
}
void caddw(unsigned char wdata)
{IOWR(LCD_DB_BASE,1,1);
IOWR(LCD_CD_BASE,0,1);
IOWR(LCD_CS_BASE,0,0);
IOWR(LCD_WR_BASE,0,0);
IOWR(LCD_RD_BASE,0,1);
IOWR(LCD_DB_BASE,0,wdata);
IOWR(LCD_WR_BASE,0,1);
IOWR(LCD_CS_BASE,0,1);
}
void daddw(unsigned char wdata)
{IOWR(LCD_DB_BASE,1,1);
IOWR(LCD_CD_BASE,0,1);
IOWR(LCD_CS_BASE,0,1);
IOWR(LCD_WR_BASE,0,0);
IOWR(LCD_RD_BASE,0,1);
IOWR(LCD_DB_BASE,0,wdata);
IOWR(LCD_WR_BASE,0,1);
}
void st01(void)
{unsigned char result;
a:
result=caddr()&0x03;
if(result!=0x03)
goto a;
}
//????S3???????????
void st3(void)
{unsigned char result;
b:
result=caddr()&0x08;
if(result==0)
goto b;
}
//?????????
void pr11(unsigned char dat,unsigned char com)//???????????
{st01();
daddw(dat);
st01();
caddw(com);
}
void pr12(unsigned char com)//?????????
{st01();
caddw(com);
}


void pr1(dat1,dat2,com)//???????????
{st01();
daddw(dat1);
st01();
daddw(dat2);
st01();
caddw(com);
  }
void lcdinit(void)//?????????
{pr12(0x90);         //????????????????
pr1(0x00,0x00,0x40);//???????????
pr1(0x20,0x00,0x41);//?????????????????????
pr1(0x00,0x08,0x42);//??????????????????????
pr1(0x20,0x00,0x43);//???????????????????????????????
pr12(0xa7);         //??????
pr12(0x80);         //??????????????????CGROM,??CGRAM
pr12(0x9c);
}
void clear(void)//????????
{unsigned int i;
pr1(0x00,0x00,0x24);//??????????
pr12(0xb0);         //???????
for(i=0;i<8192;i++)
{st3();
  daddw(0x000);
  }
pr12(0xb2);         //?????????
}

void wri_cc(unsigned char code,unsigned char x,unsigned char y)  //y:0-127 x:0-29
{  unsigned int xy;
   unsigned int hz;
   unsigned char xtemp,ytemp,i;
   xy=y*0x20+x+0x0800;
   hz=code*0x20;
   for(i=0;i<16;i++)
   {  xtemp=(unsigned char)(xy&0x00ff);
      ytemp=(unsigned char)((xy>>8)&0x00ff);
      pr1(xtemp,ytemp,0x24);   //????RAM??
      pr11(cc_tab[hz++],0xc0);
      pr11(cc_tab[hz++],0xc0);
      xy+=0x20;
     
    }

}

void wri_ee(unsigned char code,unsigned char x,unsigned y)
{ unsigned int xy;
   unsigned int zm;
   unsigned char xtemp,ytemp,i;
   xy=y*0x20+x+0x0800;
   zm=code*0x10;
   for(i=0;i<16;i++)
   {  xtemp=(unsigned char)(xy&0x00ff);
      ytemp=(unsigned char)((xy>>8)&0x00ff);
      pr1(xtemp,ytemp,0x24);   //????RAM??
      pr11(ee_tab[zm++],0xc0);
      xy+=0x20;
    }

}

void wri_dot(unsigned char dot,unsigned char x,unsigned char y)
{  unsigned int xy;
   unsigned char xtemp,ytemp,com;
   xy=y*0x20+x/8+0x0800;
   xtemp=(unsigned char)(xy&0x00ff);
   ytemp=(unsigned char)((xy>>8)&0x00ff);
   pr1(xtemp,ytemp,0x24);   //????RAM??
   com=(~(x%8))&0x07;
   if(dot)
   com=com|0xf8;
   else
   com=com|0xf0;
   pr12(com);

}
/*****************************************************************************/
/* main
/*****************************************************************************/
unsigned char sindata[64];
float rad;         
int main(void)
{   unsigned int cnt;
    unsigned char changereg;
    lcdinit();
    clear();
    wri_ee(40,3,0);
    wri_ee(39,4,0);
    wri_ee(36,5,0);
    wri_cc(0,6,0);
    wri_cc(1,8,0);
    wri_cc(2,10,0);
    wri_ee(39,2,16);
    wri_ee(54,3,16);
    wri_ee(51,4,16);
    wri_cc(0,5,16);
    wri_cc(1,7,16);
    wri_cc(3,9,16);
    wri_cc(4,11,16);
   
   }
不好意思,我一般用ks0108的,很少用t6963的。
在交流中前进,共同实现nios的应用。
返回列表