超级郁闷,LCM无法显示

[复制链接]
2427|7
 楼主| wcnndgcd 发表于 2010-9-28 21:24 | 显示全部楼层 |阅读模式
各位大虾帮忙看看程序有什么问题。谢谢
使用rt12232F,有字库,并口连接,P0口已加上拉

#include "r51r.h"
#include  <intrins.h>
#include  <stdio.h>
#include  <stdlib.h>
#define   uchar unsigned char
#define   uint unsigned int
#define   ulong unsigned long
#define   ture   1
#define   false  0
void  delay1ms(uint time){
      uchar i;
      uint j;  
     for(j=0;j<time;j++){         
       for(i=0;i<100;i++){
        _nop_();_nop_();_nop_();
        _nop_();_nop_();_nop_();  
        _nop_();_nop_();_nop_();
        _nop_();_nop_();_nop_();  
        _nop_();_nop_();_nop_();
        _nop_();  
        _nop_();}
        }
      }
sbit busy=P0^7;
sbit LED = P1^3;
sbit RS = P1^0;
sbit RW = P3^6;
sbit E1 = P3^7;
//sfr  AUXR= 0X8E;   
void LCDCMD(uchar command){
     delay1ms(100);
     RS = 0; RW = 0;
     P0 = command;
     E1 = 1; _nop_(); E1 = 0;
}
void DispData(uchar temp){
     delay1ms(100);
     RS = 1; RW = 0;
     P0 = temp;
     E1 = 1; _nop_(); E1 = 0;
}
void Test(void)
{   
    LCDCMD(0x30);
    LCDCMD(0x06);
    LCDCMD(0x0c);
    LCDCMD(0x01);
    LCDCMD(0x02);
   LCDCMD(0x80);
    DispData(0xb7);
    DispData(0xb4);
}
main(){
       EA=0;  
delay1ms(100);
   LED = 0;
   delay1ms(550);
Test();
   while(1)
   {
      LED = 0;
      delay1ms(400);        
      LED = 1;
      delay1ms(400);
   }
}
 楼主| wcnndgcd 发表于 2010-9-28 21:26 | 显示全部楼层
只有黑屏,郁闷
lovedfrien 发表于 2010-9-28 21:53 | 显示全部楼层
调节背光,可能是硬件问题
 楼主| wcnndgcd 发表于 2010-9-28 22:14 | 显示全部楼层
回楼上,背光没接,能看到两行黑的点阵
efen 发表于 2010-9-28 23:49 | 显示全部楼层
调节下对比度
teddeng 发表于 2010-9-29 00:47 | 显示全部楼层
这个代码是你写的还是厂家提供的演示代码?是演示代码查接线;自己写的话先找演示代码点亮再说吧。用ST7920去搜,一般都这芯片做的模块。
 楼主| wcnndgcd 发表于 2010-9-29 08:17 | 显示全部楼层
本帖最后由 wcnndgcd 于 2010-9-29 08:18 编辑

自己写的,没找到例程,硬件 连接线查了很多遍了,没问题
zkkov2000 发表于 2010-9-29 11:33 | 显示全部楼层
void LCDCMD(uchar command){
     delay1ms(100);
     RS = 0; RW = 0;
     P0 = command;
     E1 = 1; _nop_(); E1 = 0;
}
void DispData(uchar temp){
     delay1ms(100);
     RS = 1; RW = 0;
     P0 = temp;
     E1 = 1; _nop_(); E1 = 0;
}
你的这个程序感觉有问题啊。
是下降沿写入数据还是上升沿?一个NOP的时间是多长?能满足资料对电平持续时间的最低要求吗?你把资料对液晶模块驱动时序好好看看,看时间长短,时序先后看明白了。我写的程序你参考下(能使):
/*********************************
函数名称:WriteDataLCM(uint lcd_cmd)写指令
入口参数:lcd_cmd
返回参数:无
*********************************/
void WriteCmd12832(uchar lcd_cmd)
{
        LCD_RS=LOW;                       
        LCD_RW=LOW;                       
        LCD_E=HIGH;               
        LCD_DATA=lcd_cmd;
        Delayms(1);
        LCD_E=LOW;
        Delayms(1);
        LCD_E=HIGH;               
}


/********************************
函数名称:WriteDataLCM(uint lcd_data)写数据
入口参数:current_data
返回参数:无
********************************/
void WriteDataLCM(uchar lcd_data)
{
        LCD_RS=HIGH;
        LCD_RW=LOW;
        LCD_E=HIGH;
        LCD_DATA=lcd_data;
        Delayms(1);
        LCD_E=LOW;
        Delayms(1);
        LCD_E=HIGH;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

5

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部