感谢您的光临。
我正在尝试使用基于Hitachi HD44的全新Midas MC21605G12W LCD显示器。我使用PIC16。
我彻底关注了数据表,但无法做出任何反应。显示屏保持显示正方形而不闪烁。网站上的任何主题都无法帮助我。
我通过8位并行接口,所以我的所有端口C都连接到DB0-DB7。
如果有人能告诉我任何错误,那就太棒了。
提前感谢您的时间: - )
这是我的代码:
#include <stdio.h>
#include <pic16f18875.h>
#define RS LATBbits.LATB5 //data or instruction(LOW))
#define E LATBbits.LATB7 //chip enable
int i; //for counters of delays
/******************************MAIN************************************************/
void main()
{
TRISC = 0x00; //défine in/outs
TRISB = 0x00; //Port B is for commands, port C is
//for 8bit data and instructions
ANSELC = 0x00;
ANSELB = 0x00;
LATC = 0x00;
LATB = 0x00;
RS=0; //we start with instructions
E=0; //enable is initiated at zero
LATC=0b00111100; //select function
for (i=0;i<15;i++){} //setting of the port (delay)
E=1; //enable pulse
for (i=0;i<1;i++){} //ensure it is read
E=0;
for (i=0;i<12000;i++){} //lcd internal operations
LATC=0b00001111; //display on
for (i=0;i<15;i++){}
E=1;
for (i=0;i<1;i++){}
E=0;
for (i=0;i<12000;i++){}
LATC=0x01; //clear display
for (i=0;i<15;i++){}
E=1;
for (i=0;i<1;i++){}
E=0;
for (i=0;i<12000;i++){}
LATC=0x07; //select position of cursor
for (i=0;i<15;i++){}
E=1;
for (i=0;i<1;i++){}
E=0;
for (i=0;i<12000;i++){}
RS=1; //now we will send data
LATC=0x41; //display "A" (ascii)
for (i=0;i<15;i++){}
E=1;
for (i=0;i<1;i++){}
E=0;
for (i=0;i<12000;i++){}
RS=0;
while(1)
{}
}