还是没用,我把延时改了6倍,还是白屏。
请帮忙看一下代码,谢谢了
//#include
#include "STC15.H"
#include //Keil library
#include //Keil library
#include
//#include "STC15Fxxxx.H"
#define Busy 0x80
#define LCDdata P0
//typedef unsigned char uchar;
typedef unsigned short ushort;
//typedef unsigned int uint;
#define uint unsigned int
#define uchar unsigned char
uchar seg0[]="X:";
uchar seg1[]="Y:";
//uchar seg2[]="Z:";
//****************************************
// ??51?????
//****************************************
//#define DataPort P0 //LCD1602????
***it SCL=P1^0; //IIC??????
***it SDA=P1^1; //IIC??????
/****it LCM_RS=P2^4; //LCD1602????
***it LCM_RW=P2^5; //LCD1602????
***it LCM_EN=P2^6; //LCD1602????
*/
***it E=P2^7;
***it RW=P2^6;
***it RS=P2^5;
***it RST=P2^3;
//****************************************
// ??MPU6050????
//****************************************
#define SMPLRT_DIV 0x19 //??????,???:0x07(125Hz)
#define CONFIG 0x1A //??????,???:0x06(5Hz)
#define GYRO_CONFIG 0x1B //??????????,???:0x18(???,2000deg/s)
#define ACCEL_CONFIG 0x1C //?????????????????,???:0x01(???,2G,5Hz)
#define ACCEL_XOUT_H 0x3B
#define ACCEL_XOUT_L 0x3C
#define ACCEL_YOUT_H 0x3D
#define ACCEL_YOUT_L 0x3E
#define ACCEL_ZOUT_H 0x3F
#define ACCEL_ZOUT_L 0x40
#define TEMP_OUT_H 0x41
#define TEMP_OUT_L 0x42
#define GYRO_XOUT_H 0x43
#define GYRO_XOUT_L 0x44
#define GYRO_YOUT_H 0x45
#define GYRO_YOUT_L 0x46
#define GYRO_ZOUT_H 0x47
#define GYRO_ZOUT_L 0x48
#define PWR_MGMT_1 0x6B //????,???:0x00(????)
#define WHO_AM_I 0x75 //IIC?????(????0x68,??)
#define SlaveAddress 0xD0 //IIC??????????,+1???
//****************************************
//???????
//****************************************
uchar dis[4]; //????(-511?512)?????
int dis_data; //??
//int Temperature,Temp_h,Temp_l;
//????????
//****************************************
//????
//****************************************
void delay(unsigned int xx); //??
//LCD????
//void InitLcd(); //???lcd1602
//void lcd_printf(uchar *s,int temp_data);
/*void WriteDataLCM(uchar dataW); //LCD??
void WriteCommandLCM(uchar CMD,uchar Attribc); //LCD??
void DisplayOneChar(uchar X,uchar Y,uchar DData); //??????
void DisplayListChar(uchar X,uchar Y,uchar *DData,L);
//????? */
//MPU6050????
void InitMPU6050(); //???MPU6050
void Delay5us();
void I2C_Start();
void I2C_Stop();
void I2C_SendACK(bit ack);
bit I2C_RecvACK();
void I2C_SendByte(uchar dat);
uchar I2C_RecvByte();
void I2C_ReadPage();
void I2C_WritePage();
void display_ACCEL_x();
void display_ACCEL_y();
void display_ACCEL_z();
uchar Single_ReadI2C(uchar REG_Address); //??I2C??
void Single_WriteI2C(uchar REG_Address,uchar REG_data);
//?I2C????
//****************************************
//??????
//****************************************
void lcd_printf(uchar *s,int temp_data)
{
if(temp_data<0)
{
temp_data=-temp_data;
*s='-';
}
else *s=' ';
*++s =temp_data/100+0x30;
temp_data=temp_data%100; //????
*++s =temp_data/10+0x30;
temp_data=temp_data%10; //????
*++s =temp_data+0x30;
}
//****************************************
//??
//****************************************
void delay1(unsigned int k)
{
unsigned int i,j;
for(i=0;i<(6*k);i++)
{
for(j=0;j<121;j++);
}
}
//****************************************
//LCD1602???
//****************************************
void delay(uint xx) //??5ms
{
unsigned int yy;
yy=6*xx;
while(yy--);
}
void rdbf(void) //????
{
while(1)
{
RS=0;
RW=1;
E=0;
LCDdata=0xFF;
E=1;
if((LCDdata&Busy)==0)
break;
}
}
void wr_data(uchar wrdata) //???
{
rdbf();
RS=1;
RW=0;
E=1;
LCDdata=wrdata;
E=0;
}
void wr_cmd(uchar wrcmd,busyc) //???(???,??)
{
if(busyc)
rdbf(); //?BF=0?,????????????
RS=0;
RW=0;
E=1;
LCDdata=wrcmd;
E=0;
}
void display(uchar x,uchar y,uchar *seg) //x???,y???
{
uchar i;
uint t=0;
switch(x) //????
{
case 1: i=0x80; break;
//???
case 2: i=0x90; break;
//???
case 3: i=0x88; break;
//???
case 4: i=0x98; break;
//???
default : break;
}
i=i+y-1; //????
wr_cmd(i,1);
while(seg[t]!=' |