打印

LPC2131接24064液晶程序总是停在忙检测

[复制链接]
2164|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lnww|  楼主 | 2008-4-26 16:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我用LPC2131接24064液晶(型号Ocmj4×15D 控制器8822 金鹏产品)不知为什么屏幕没显示  调试发现程序总是停留在判忙信号检测上,谢谢提供解决方法,程序如下  数据口接P0.0~P0.7

#include "config.h"
uint8 tab1[]={
  "冷箱    ℃  时钟显示   :  :   "
  "冷头    ℃  休眠停止    :     "
  "冷台    ℃  休眠开始    :     "
  "冷刀    ℃                    "};
  
#define lcd_rs   1<<8
#define lcd_wr   1<<9
#define lcd_rd   1<<10
#define lcd_cs1  1<<12
#define lcd_cs2  1<<13
#define lcd_busy 1<<17
#define lcd_int  1<<18
#define lcd_rst  1<<19

/*********************************************************************************************/
void delay(uint16 k)
{
  uint16 i;
  for(i=0;i<k;i++);
}
void delay1(uint32 ms)
{
  uint32 i,j;
  for(i=0;i<ms;i++)
    for(j=0;j<400;j++);
}
//=============================================
void lcd_regwr(uint8 regnada)
{ IO0CLR = 0xff;       //先清零
  IO0SET = regnada;  //再送数
  IO0CLR = lcd_cs1;  // chip enable.
  IO0SET = lcd_rd;   //
  IO0CLR = lcd_rs;   // rs = 0;
  IO0CLR = lcd_wr;   // wr = 0;
  delay(10);
  IO0SET = lcd_wr;   // wr = 1;
  IO0SET = lcd_rs;   // rs = 1;
  IO0SET = lcd_cs1;  // chip disable.
}

void lcd_regwrite(uint8 regname,uint8 regdata) 
{                                   //写资料到缓存器
  lcd_regwr(regname);
  delay(10);
  lcd_regwr(regdata);
}

//.............................................
void lcd_datawrite(uint8 wrdata) 
{                        //写资料到DDRAM
  while(!(IO0PIN&lcd_busy) == 0);
  IO0CLR = 0xff;   //先清零
  IO0SET = wrdata; //再送数
  IO0CLR = lcd_cs1; // chip enable.
  IO0SET = lcd_rd; //
  IO0SET = lcd_rs; // rs = 1;
  IO0CLR = lcd_wr; // wr = 0;
  delay(10);
  IO0SET = lcd_wr; // wr = 1;
  IO0SET = lcd_rs; // rs = 1;
  IO0SET = lcd_cs1; // chip disable.
}
//.............................................
uint8 lcd_regread(uint8 regname) 
{                           //读缓存器
  uint8 reg_rddata;  
  lcd_regwr(regname);

  IO0DIR=0x00;
  IO0SET = 0xff;
  IO0CLR = lcd_cs1; // chip enable.
  IO0SET = lcd_wr; // wr = 1;
  IO0CLR = lcd_rs; // rs = 0;
  IO0CLR = lcd_rd; // rd = 0;
  ;
  reg_rddata = (IO0PIN&0xff);
  IO0SET = lcd_rd; // rd = 1;
  IO0SET = lcd_rs; // rs = 1;
  IO0SET = lcd_cs1; // chip disable.
  
  IO0DIR=0xff;
  return(reg_rddata);
}
//.............................................
 void gotoxy(uint8 x,uint8 y)
{                                //定坐标
  lcd_regwrite(0x60,x); // active window top register(awtr)
  lcd_regwrite(0x70,y); // active window top register(awtr)
}
//=============================================

void lcd_reset(void) 
{               //上电复位
  delay1(800); // delay 120ms 等待上电复位
  IO0SET = 0x000e37ff; // lcd_rs/wr/rd/cs1/cs2 normal - skeep high.
}
//.............................................
void lcd_initial(void) 
{                   //初始化
  lcd_regwrite(0x00,0xc9); // lcd control register(lcr)
  lcd_regwrite(0x01,0xf2); // misc.register(mir)
  lcd_regwrite(0x02,0x10); // advance power setup register(apsr)
  lcd_regwrite(0x03,0x80); // advance display setup regiser(adsr)
  lcd_regwrite(0x10,0x6b); // cursor control register(ccr)
  lcd_regwrite(0x11,0x00); // distance of word or lines register(dwlr)
  lcd_regwrite(0x12,0x91); // memory access mode register(awrr)
  lcd_regwrite(0x21,0x1d); // display window right register(dwrr) 
  lcd_regwrite(0x31,0x3f); // display window bottom register(dwbr) 
  lcd_regwrite(0x41,0x00); // display window left register(dwlr)
  lcd_regwrite(0x51,0x00); // display window top register(dwtr)
  lcd_regwrite(0x20,0x1d); // active window right register(awrr) 
  lcd_regwrite(0x30,0x3f); // active window bottom register(awbr)
  lcd_regwrite(0x40,0x00); // active window left register(awlr)
  lcd_regwrite(0x50,0x00); // active window top register(awtr)
  lcd_regwrite(0x60,0x00); // cursor position x register(cpxr)
  lcd_regwrite(0x61,0x00); // begin segment position register(bgsg)
  lcd_regwrite(0x70,0x00); // cursor position y register(cpyr)
  lcd_regwrite(0x71,0x00); // shift action range,begin commom register(bgcm)
  lcd_regwrite(0x72,0x3f); // shift action range,end commom register(edcm) 
  lcd_regwrite(0x80,0xaa); // blink time register(btr)
  lcd_regwrite(0x81,0x00); // frame rate polarity change at common_fa register(fdca)
  lcd_regwrite(0x91,0x00); // frame rate polarity change at common_fb register(fdcb)
  lcd_regwrite(0x90,0x1e); // shift clock control register(sccr)  
  lcd_regwrite(0xa0,0x08); // interrupt setup & status register(frcb)
  lcd_regwrite(0xa1,0xf1); // key scan control register(kscr)
  lcd_regwrite(0xa2,0x00); // key scan data register(ksdr)
  lcd_regwrite(0xa3,0x00); // key scan data expand register(kser)
  lcd_regwrite(0xb0,0x1d); // interrupt column setup register(intx) 
  lcd_regwrite(0xb1,0x3f); // interrupt row setup register(inty)  
  lcd_regwrite(0xc0,0x00); // touch panel control register(tpcr)
  lcd_regwrite(0xc1,0x0a); // adc status register(adcs)
  lcd_regwrite(0xc8,0x80); // touch panel segment high byte data register(tpxr)
  lcd_regwrite(0xc9,0x80); // touch panel common high byte data register(tpyr)
  lcd_regwrite(0xca,0x00); // touch panel segment/common low byte data register(tpzr)
  lcd_regwrite(0xd0,0x80); // lcd contrast control register (lccr)
  lcd_regwrite(0xe0,0x00); // pattern data register(pdr)
  lcd_regwrite(0xf0,0xa0); // font control register(fcr)
  lcd_regwrite(0xf1,0x0f); // font size control register
}
//.............................................

//.............................................
void lcd_character(uint8 *cha,uint8 count)
{                                    //显示中文或字符
  uint8 i;
  for(i=0;i<count;i++)
  {
    lcd_datawrite(*cha);
    ++cha;
  }
}

int main (void)

  
  PINSEL0=0x00000000;
  PINSEL1=0x00000000;
  IO0DIR=0x000e37ff;     //设置输出口
  
  IO0SET=0x000e37ff;
  lcd_reset();
  lcd_initial();             //初始化中 液晶关显示
  

  lcd_regwrite(0x10,0x6b);
  lcd_regwrite(0x00,0xcd);   // 液晶开显示
  gotoxy(0x00,0x00);       //设定显示位置
  lcd_character(tab1,120);
  
  while(1);
    return 0;
}

相关帖子

沙发
wishcom| | 2008-4-26 17:13 | 只看该作者

很怀疑你的忙信号是不是搞反了

检查一下忙信号到底是高有效还是低有效吧

使用特权

评论回复
板凳
lnww|  楼主 | 2008-4-27 08:44 | 只看该作者

忙信号是高电平表示忙 没有搞错

忙信号是高电平表示忙  没有搞错

使用特权

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

本版积分规则

52

主题

104

帖子

1

粉丝