大家好,我的这个程序是用来1602液晶显示的,不知怎么搞的,在,maplab上面仿真,用C口做控制口有用,用AB都没反应啊
#include <P18F4620.h>
#define ldata PORTD
#define rs PORTBbits.RB0
#define rw PORTBbits.RB1
#define en PORTBbits.RB2
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void MSDelay(unsigned int itime);
void main()
{
TRISD=0;
OPTION=0x07;
PORTB=0xFF;
PORTBbits.RB2=0;
MSDelay(250);
lcdcmd(0x38);
MSDelay(250);
lcdcmd(0x0E);
MSDelay(15);
lcdcmd(0x01);
MSDelay(15);
lcdcmd(0x06);
MSDelay(15);
lcdcmd(0x86);
MSDelay(15);
lcddata('M');
MSDelay(15);
lcddata('D');
MSDelay(15);
lcddata('E');
}
void lcdcmd(unsigned char value)
{
ldata=value;
PORTBbits.RB0=0;
rw=0;
PORTBbits.RB2=1;
MSDelay(10);
PORTBbits.RB2=0;
}
void lcddata(unsigned char value)
{
ldata=value;
PORTBbits.RB0=1;
rw=0;
PORTBbits.RB2=1;
MSDelay(10);
PORTBbits.RB2=0;
}
void MSDelay(unsigned int itime)
{
unsigned int i,j;
for (i=0;i<itime;i++)
for(j=0;j<135;j++);
} |