打印

请教lcd1602的问题用icd2。。。。

[复制链接]
1314|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jianghuoo00|  楼主 | 2011-11-5 10:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jianghuoo00 于 2011-11-5 10:18 编辑

使用icd2调试的,为什么LCD1602不显示?是程序的问题吗?单片机上没有晶振,开始调试时出现icd2x083的错误,后来请教他人加上了红字配置晶振,没有错误了,可是lcd为什么不显示呢?请教高手。感谢回答参考 LCD1602液晶中文资料[1].pdf (299.6 KB)

#include<p33FJ64MC506.h>
#define uchar unsigned char
#define uint unsigned int
#define LCD_RS LATDbits.LATD5
#define LCD_RW LATDbits.LATD6
#define LCD_E LATDbits.LATD7
const uchar table1[]="LCD1602 CHECK OK";   
const uchar table2[]="1602 OK";
void init();
void LCD_init();
void delay(uint x);
void LCD_wcom(uint com);
void LCD_wdat(uint data);
int main(void)                    //主函数
{
    //Configure Oscillator to operate the device at 80Mhz
    PLLFBD=41; // M=20
    CLKDIVbits.PLLPOST=0; // N1=2
    CLKDIVbits.PLLPRE=0; // N2=2
                         // Clock switching to incorporate PLL
    __builtin_write_OSCCONH(0x01); //Initiate Clock Switch to Primary
                                  //FRC with PLL (NOSC=0b001)
    __builtin_write_OSCCONL(0x01); //Start clock switching
    while (OSCCONbits.COSC != 0b001); // Wait for Clock switch to occur   
uchar m,n;
init();
LCD_init();
LCD_wcom(0x80);               //第一行显示
for(m=0;m<16;m++)
{
  LCD_wdat(table1[m]);
  delay(200);
}
LCD_wcom(0x80+0x40);          //第二行显示  
for(n=0;n<7;n++)
{
  LCD_wdat(table2[n]);
  delay(200);
}
while(1);
}
void init()          //初始化
{
TRISD=0;
//LATD=0;
TRISE=0;
//LATE=0;
}
void LCD_init()       //LCD初始化
{
delay(15);
LCD_wcom(0x38);
delay(5);
LCD_wcom(0x38);
delay(5);
LCD_wcom(0x38);
LCD_wcom(0x38);
LCD_wcom(0x08);
LCD_wcom(0x01);
LCD_wcom(0x06);
LCD_wcom(0x0c);
}
void delay(uint x)   //延时
{
uint a,b;
for(a=x;a>0;a--)
  for(b=110;b>0;b--);
}
void LCD_wcom(uint com)     //1602写指令
{
LCD_RS=0;
LCD_RW=0;
LATE=com;
delay(5);
    LCD_E=0;
    delay(5);
LCD_E=1;
delay(5);
}
void LCD_wdat(uint dat)       //写数据
{
LCD_RS=1;
LCD_RW=0;
LATE=dat;
delay(5);
    LCD_E=0;
    delay(5);
LCD_E=1;
delay(5);
}
沙发
wangz2011| | 2011-11-10 21:51 | 只看该作者
检查下你所用1602的 LCD_E 工作方式。

使用特权

评论回复
板凳
jianghuoo00|  楼主 | 2011-11-11 10:46 | 只看该作者
2# wangz2011
谢谢啊,已经解决了,是v0电压大,有点亮,没调好

使用特权

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

本版积分规则

0

主题

98

帖子

1

粉丝